diff --git a/db/data/20260820162538_backfill_use_for_projections_from_concealment.rb b/db/data/20260820162538_backfill_use_for_projections_from_concealment.rb new file mode 100644 index 000000000..abdc3e99d --- /dev/null +++ b/db/data/20260820162538_backfill_use_for_projections_from_concealment.rb @@ -0,0 +1,21 @@ +class BackfillUseForProjectionsFromConcealment < ActiveRecord::Migration[8.1] + # Per #2229: use_for_projections replaces the concealment predicate in the + # projection engine's event selection. Seed it from the current behavior + # (concealed event groups are excluded) so the flag's introduction is + # invisible at rollout; after this, the two move independently. + def up + updated = execute(<<~SQL.squish) + update events + set use_for_projections = false + from event_groups + where event_groups.id = events.event_group_id + and event_groups.concealed is true + SQL + say "Set use_for_projections = false on #{updated.cmd_tuples} events in concealed event groups" + end + + def down + # No-op. The flag decouples from concealment going forward, so there is + # no prior state to restore beyond the column default. + end +end diff --git a/db/data_schema.rb b/db/data_schema.rb index 5b91a5396..21a3ab9ae 100644 --- a/db/data_schema.rb +++ b/db/data_schema.rb @@ -1 +1 @@ -DataMigrate::Data.define(version: 2026_05_09_033127) +DataMigrate::Data.define(version: 2026_08_20_162538) diff --git a/db/migrate/20260820162536_add_use_for_projections_to_events.rb b/db/migrate/20260820162536_add_use_for_projections_to_events.rb new file mode 100644 index 000000000..a582033ed --- /dev/null +++ b/db/migrate/20260820162536_add_use_for_projections_to_events.rb @@ -0,0 +1,5 @@ +class AddUseForProjectionsToEvents < ActiveRecord::Migration[8.1] + def change + add_column :events, :use_for_projections, :boolean, default: true, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index 0acd1e287..674d4d0f1 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_07_29_185523) do +ActiveRecord::Schema[8.1].define(version: 2026_08_20_162536) do # These are extensions that must be enabled in order to support this database enable_extension "fuzzystrmatch" enable_extension "pg_catalog.plpgsql" @@ -308,6 +308,7 @@ t.string "slug", null: false t.string "topic_resource_key" t.datetime "updated_at", precision: nil, null: false + t.boolean "use_for_projections", default: true, null: false t.index ["course_id"], name: "index_events_on_course_id" t.index ["event_group_id", "short_name"], name: "index_events_on_event_group_id_and_short_name", unique: true t.index ["event_group_id"], name: "index_events_on_event_group_id" diff --git a/erd.mmd b/erd.mmd index 35c7033f5..db811df87 100644 --- a/erd.mmd +++ b/erd.mmd @@ -183,6 +183,7 @@ erDiagram string short_name string slug string topic_resource_key + boolean use_for_projections } EventGroup { boolean available_live