Browse Source
While migrating users from the previous service to the new one we discovered that email addresses are not unique in the previous service. This means that one user in the new service might relate to multiple users in the previous service. This change adds a new `LegacyUser` model that can belong to a `User`. Each `LegacyUser` model has one `old_user_id` that corresponds to the user ID in the legacy service. When importing users we now create this association.pull/894/head
11 changed files with 88 additions and 22 deletions
@ -0,0 +1,5 @@
|
||||
class LegacyUser < ApplicationRecord |
||||
belongs_to :user |
||||
|
||||
validates :old_user_id, uniqueness: true |
||||
end |
@ -0,0 +1,12 @@
|
||||
class CreateLegacyUsers < ActiveRecord::Migration[7.0] |
||||
def change |
||||
create_table :legacy_users do |t| |
||||
t.string :old_user_id |
||||
t.integer :user_id |
||||
|
||||
t.timestamps |
||||
end |
||||
|
||||
add_index :legacy_users, :old_user_id, unique: true |
||||
end |
||||
end |
@ -0,0 +1,6 @@
|
||||
FactoryBot.define do |
||||
factory :legacy_user do |
||||
old_user_id { } |
||||
user |
||||
end |
||||
end |
Loading…
Reference in new issue