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
|
||||
+6
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.2].define(version: 2025_11_25_130010) do
|
||||
ActiveRecord::Schema[8.2].define(version: 2025_11_27_000001) do
|
||||
create_table "accesses", id: :uuid, force: :cascade do |t|
|
||||
t.datetime "accessed_at"
|
||||
t.uuid "account_id", null: false
|
||||
@@ -25,6 +25,11 @@ ActiveRecord::Schema[8.2].define(version: 2025_11_25_130010) do
|
||||
t.index ["user_id"], name: "index_accesses_on_user_id"
|
||||
end
|
||||
|
||||
create_table "account_external_id_sequences", force: :cascade do |t|
|
||||
t.bigint "value", default: 0, null: false
|
||||
t.index ["value"], name: "index_account_external_id_sequences_on_value", unique: true
|
||||
end
|
||||
|
||||
create_table "account_join_codes", id: :uuid, force: :cascade do |t|
|
||||
t.uuid "account_id", null: false
|
||||
t.string "code", limit: 255, null: false
|
||||
|
||||
Reference in New Issue
Block a user