Use dedicated sequence record instead of deal with issues with ids and uuids when using the previous approach
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
class CreateAccountExternalIdSequences < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :account_external_id_sequences do |t|
|
||||
t.bigint :value, null: false, default: 0
|
||||
|
||||
t.index :value, unique: true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,15 +0,0 @@
|
||||
class CreateExternalAccounts < ActiveRecord::Migration[8.0]
|
||||
def up
|
||||
create_table :external_accounts do |t|
|
||||
end
|
||||
|
||||
max_id = Account.maximum(:external_account_id) || 0
|
||||
if max_id > 0
|
||||
execute "INSERT INTO external_accounts (id) VALUES (#{max_id})"
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
drop_table :external_accounts
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user