discourse/db/migrate/20201109170951_migrate_github_user_infos.rb
David Taylor cf21de0e7a
DEV: Migrate Github authentication to ManagedAuthenticator (#11170)
This commit adds an additional find_user_by_email hook to ManagedAuthenticator so that GitHub login can continue to support secondary email addresses

The github_user_infos table will be dropped in a follow-up commit.

This is the last core authenticator to be migrated to ManagedAuthenticator 🎉
2020-11-10 10:09:15 +00:00

30 lines
594 B
Ruby

# frozen_string_literal: true
class MigrateGithubUserInfos < ActiveRecord::Migration[6.0]
def up
execute <<~SQL
INSERT INTO user_associated_accounts (
provider_name,
provider_uid,
user_id,
info,
last_used,
created_at,
updated_at
) SELECT
'github',
github_user_id,
user_id,
json_build_object('nickname', screen_name),
updated_at,
created_at,
updated_at
FROM github_user_infos
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end