diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-30 19:15:22 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-30 19:22:24 +0200 |
| commit | a7a6ad786eeb9f94f7882462bccbdd31e1bb4743 (patch) | |
| tree | ecc0a17db462065b27270f7e593a8244e24c8846 /db/migrate | |
| parent | 31ca8e93efa860d73918b57ddddeaedf9917b22d (diff) | |
Phase 1: standalone events, external_url on nodes
- Migration: node_id nullable on events and occurrences, add
title/description/is_primary to events, external_url to nodes
- Existing events marked is_primary: true (were all 1:1 with nodes)
- Node: has_one :event -> has_many :events
- Event: belongs_to :node optional, validates title presence for
standalone events, is_primary uniqueness scoped to node_id,
display_title helper falling back through node title
- Occurrence: belongs_to :node optional, summary falls back to
event.display_title
- nodes_helper: event_information uses events.first (interim; will
be replaced in Phase 3 event UI)
- Tests: fix node.event -> node.events.first in event_test
Diffstat (limited to 'db/migrate')
| -rw-r--r-- | db/migrate/20260627233640_upgrade_events_and_nodes_for_standalone_events.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/db/migrate/20260627233640_upgrade_events_and_nodes_for_standalone_events.rb b/db/migrate/20260627233640_upgrade_events_and_nodes_for_standalone_events.rb new file mode 100644 index 0000000..790a62b --- /dev/null +++ b/db/migrate/20260627233640_upgrade_events_and_nodes_for_standalone_events.rb | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | class UpgradeEventsAndNodesForStandaloneEvents < ActiveRecord::Migration[8.1] | ||
| 2 | def up | ||
| 3 | # Events: make node optional, add missing fields | ||
| 4 | change_column_null :events, :node_id, true | ||
| 5 | add_column :events, :title, :string | ||
| 6 | add_column :events, :description, :text | ||
| 7 | add_column :events, :is_primary, :boolean, default: false, null: false | ||
| 8 | |||
| 9 | # Mark all existing events as primary (they were all 1:1 with nodes) | ||
| 10 | Event.where.not(node_id: nil).update_all(is_primary: true) | ||
| 11 | |||
| 12 | # Occurrences: make node optional | ||
| 13 | change_column_null :occurrences, :node_id, true | ||
| 14 | |||
| 15 | # Nodes: add external URL | ||
| 16 | add_column :nodes, :external_url, :string | ||
| 17 | end | ||
| 18 | |||
| 19 | def down | ||
| 20 | remove_column :nodes, :external_url | ||
| 21 | change_column_null :occurrences, :node_id, false | ||
| 22 | remove_column :events, :is_primary | ||
| 23 | remove_column :events, :description | ||
| 24 | remove_column :events, :title | ||
| 25 | change_column_null :events, :node_id, false | ||
| 26 | end | ||
| 27 | end | ||
