Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions script/backfill-linked-accounts.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
INSERT INTO linked_accounts (user_id, provider, account_id, access_token, login, avatar)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll likely want a benchmark on this to see if it takes long enough that it needs to be broken into smaller batches, but my instinct says this approach is probably fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm starting to think I want a more general sort of harness for running SQL in a loop of batches of N until it returns 0 results, because a few of these migrations are going to need to do that sort of thing...

SELECT id, 0, gh_id, gh_access_token, gh_login, gh_avatar
FROM users
LEFT JOIN linked_accounts
ON users.id = linked_accounts.user_id
WHERE gh_id != -1
AND linked_accounts.user_id IS NULL;