From a7a6ad786eeb9f94f7882462bccbdd31e1bb4743 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Tue, 30 Jun 2026 19:15:22 +0200 Subject: 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 --- ...grade_events_and_nodes_for_standalone_events.rb | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 db/migrate/20260627233640_upgrade_events_and_nodes_for_standalone_events.rb (limited to 'db/migrate') 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 @@ +class UpgradeEventsAndNodesForStandaloneEvents < ActiveRecord::Migration[8.1] + def up + # Events: make node optional, add missing fields + change_column_null :events, :node_id, true + add_column :events, :title, :string + add_column :events, :description, :text + add_column :events, :is_primary, :boolean, default: false, null: false + + # Mark all existing events as primary (they were all 1:1 with nodes) + Event.where.not(node_id: nil).update_all(is_primary: true) + + # Occurrences: make node optional + change_column_null :occurrences, :node_id, true + + # Nodes: add external URL + add_column :nodes, :external_url, :string + end + + def down + remove_column :nodes, :external_url + change_column_null :occurrences, :node_id, false + remove_column :events, :is_primary + remove_column :events, :description + remove_column :events, :title + change_column_null :events, :node_id, false + end +end -- cgit v1.3