diff --git a/app/models/account_relationship_severance_event.rb b/app/models/account_relationship_severance_event.rb index 0cf3fb117d4..32b185e3af6 100644 --- a/app/models/account_relationship_severance_event.rb +++ b/app/models/account_relationship_severance_event.rb @@ -8,6 +8,7 @@ # id :bigint(8) not null, primary key # account_id :bigint(8) not null # relationship_severance_event_id :bigint(8) not null +# relationships_count :integer default(0), not null # created_at :datetime not null # updated_at :datetime not null # diff --git a/db/migrate/20240320140159_create_account_relationship_severance_events.rb b/db/migrate/20240320140159_create_account_relationship_severance_events.rb index 160ef762136..5262c508fe3 100644 --- a/db/migrate/20240320140159_create_account_relationship_severance_events.rb +++ b/db/migrate/20240320140159_create_account_relationship_severance_events.rb @@ -3,11 +3,13 @@ class CreateAccountRelationshipSeveranceEvents < ActiveRecord::Migration[7.1] def change create_table :account_relationship_severance_events do |t| - t.belongs_to :account, foreign_key: { on_delete: :cascade }, null: false, index: { unique: true } - t.belongs_to :relationship_severance_event, foreign_key: { on_delete: :cascade }, null: false, index: { unique: true } + t.belongs_to :account, foreign_key: { on_delete: :cascade }, null: false + t.belongs_to :relationship_severance_event, foreign_key: { on_delete: :cascade }, null: false t.integer :relationships_count, default: 0, null: false + t.index [:account_id, :relationship_severance_event_id], unique: true + t.timestamps end end diff --git a/db/schema.rb b/db/schema.rb index 1e1d99f26b2..9756da1af88 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -96,8 +96,9 @@ ActiveRecord::Schema[7.1].define(version: 2024_03_20_140159) do t.integer "relationships_count", default: 0, null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false - t.index ["account_id"], name: "index_account_relationship_severance_events_on_account_id", unique: true - t.index ["relationship_severance_event_id"], name: "idx_on_relationship_severance_event_id_403f53e707", unique: true + t.index ["account_id", "relationship_severance_event_id"], name: "idx_on_account_id_relationship_severance_event_id_7bd82bf20e", unique: true + t.index ["account_id"], name: "index_account_relationship_severance_events_on_account_id" + t.index ["relationship_severance_event_id"], name: "idx_on_relationship_severance_event_id_403f53e707" end create_table "account_stats", force: :cascade do |t|