You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docuseal/db/migrate/20250910191227_create_accou...

22 lines
843 B

class CreateAccountGroupsAndAddRelationships < ActiveRecord::Migration[8.0]
def change
create_table :account_groups do |t|
t.integer :external_account_group_id, null: false
t.string :name, null: false
t.timestamps
end
add_index :account_groups, :external_account_group_id, unique: true
add_reference :accounts, :account_group, foreign_key: true
add_reference :templates, :account_group, foreign_key: true
add_reference :users, :account_group, foreign_key: true
add_reference :template_folders, :account_group, foreign_key: true
# Make account_ids nullable since records can belong to either account or account_group
change_column_null :templates, :account_id, true
change_column_null :users, :account_id, true
change_column_null :template_folders, :account_id, true
end
end