diff --git a/app/models/invitation_log_entry.rb b/app/models/invitation_log_entry.rb index 552ee424d..4385b28d3 100644 --- a/app/models/invitation_log_entry.rb +++ b/app/models/invitation_log_entry.rb @@ -4,6 +4,4 @@ class InvitationLogEntry < ApplicationRecord belongs_to :invitation_log belongs_to :member belongs_to :invitation, polymorphic: true, optional: true - - validates :member_id, uniqueness: { scope: %i[invitation_type invitation_id] }, allow_nil: true end diff --git a/db/migrate/20260410174346_remove_global_unique_constraint_from_invitation_log_entries.rb b/db/migrate/20260410174346_remove_global_unique_constraint_from_invitation_log_entries.rb new file mode 100644 index 000000000..e261edeb6 --- /dev/null +++ b/db/migrate/20260410174346_remove_global_unique_constraint_from_invitation_log_entries.rb @@ -0,0 +1,13 @@ +class RemoveGlobalUniqueConstraintFromInvitationLogEntries < ActiveRecord::Migration[8.1] + def up + remove_index :invitation_log_entries, + name: 'idx_on_invitation_type_invitation_id_6d6ef495e6' + end + + def down + add_index :invitation_log_entries, + %i[invitation_type invitation_id], + name: 'idx_on_invitation_type_invitation_id_6d6ef495e6', + unique: true + end +end diff --git a/db/schema.rb b/db/schema.rb index c9369956d..1fc00de44 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2026_04_08_220120) do +ActiveRecord::Schema[8.1].define(version: 2026_04_10_174346) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -299,7 +299,6 @@ t.datetime "updated_at", null: false t.index ["invitation_log_id", "status"], name: "index_invitation_log_entries_on_invitation_log_id_and_status" t.index ["invitation_log_id"], name: "index_invitation_log_entries_on_invitation_log_id" - t.index ["invitation_type", "invitation_id"], name: "idx_on_invitation_type_invitation_id_6d6ef495e6", unique: true t.index ["invitation_type", "invitation_id"], name: "index_invitation_log_entries_on_invitation" t.index ["member_id", "processed_at"], name: "index_invitation_log_entries_on_member_id_and_processed_at" t.index ["member_id"], name: "index_invitation_log_entries_on_member_id" diff --git a/spec/models/invitation_log_entry_spec.rb b/spec/models/invitation_log_entry_spec.rb index 0c626b1e6..7ddad269e 100644 --- a/spec/models/invitation_log_entry_spec.rb +++ b/spec/models/invitation_log_entry_spec.rb @@ -16,12 +16,4 @@ }) end end - - describe 'validations' do - it 'validates uniqueness of member_id scoped to invitation' do - entry = Fabricate(:invitation_log_entry) - expect(entry).to validate_uniqueness_of(:member_id) - .scoped_to(:invitation_type, :invitation_id) - end - end end