Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/event/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# Indexes
#
# index_event_configurations_on_event_id (event_id)
# index_event_configurations_on_event_id (event_id) UNIQUE
#
# Foreign Keys
#
Expand All @@ -30,6 +30,7 @@ class Configuration < ApplicationRecord
validates_email_format_of :contact_email, allow_nil: true, allow_blank: true
normalizes :contact_email, with: ->(contact_email) { contact_email.strip.downcase }
validates :subevent_plan, inclusion: { in: -> { Event::Plan.available_plans.map(&:name) } }, allow_blank: true
validates :event, uniqueness: true

after_save :create_or_destroy_monthly_announcement

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddUniqueIndexToEventConfigurationsOnEventId < ActiveRecord::Migration[8.0]
disable_ddl_transaction!

def change
remove_index :event_configurations, :event_id

add_index :event_configurations, :event_id, unique: true, algorithm: :concurrently
end
end
2 changes: 1 addition & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@
t.boolean "generate_monthly_announcement", default: false, null: false
t.string "subevent_plan"
t.datetime "updated_at", null: false
t.index ["event_id"], name: "index_event_configurations_on_event_id"
t.index ["event_id"], name: "index_event_configurations_on_event_id", unique: true
end

create_table "event_follows", force: :cascade do |t|
Expand Down