Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add indices for meeting participants

Klaus Zanders2dad2eab9fce
diff --git a/modules/meeting/app/models/meeting_participant.rb b/modules/meeting/app/models/meeting_participant.rb
index cefe3153675..65c47752aa5 100644
--- a/modules/meeting/app/models/meeting_participant.rb
+++ b/modules/meeting/app/models/meeting_participant.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
@@ -31,6 +32,8 @@ class MeetingParticipant < ApplicationRecord
belongs_to :meeting
belongs_to :user
+ validates :user, presence: true, uniqueness: { scope: :meeting_id }
+
scope :invited, -> { where(invited: true) }
scope :attended, -> { where(attended: true) }
diff --git a/modules/meeting/db/migrate/20250821092618_add_indices_to_meeting_participants.rb b/modules/meeting/db/migrate/20250821092618_add_indices_to_meeting_participants.rb
new file mode 100644
index 00000000000..e8545c62919
--- /dev/null
+++ b/modules/meeting/db/migrate/20250821092618_add_indices_to_meeting_participants.rb
@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+class AddIndicesToMeetingParticipants < ActiveRecord::Migration[8.0]
+ disable_ddl_transaction!
+
+ def change
+ add_index :meeting_participants, :meeting_id, algorithm: :concurrently
+ add_index :meeting_participants, :user_id, algorithm: :concurrently
+
+ add_index :meeting_participants, %i[meeting_id user_id], unique: true, algorithm: :concurrently
+ end
+end