summaryrefslogtreecommitdiff
path: root/db/migrate/20260627233640_upgrade_events_and_nodes_for_standalone_events.rb
blob: 2605e5cf48ab4ed1eb3c03e789aab19486dd7c03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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

    # 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, :description
    remove_column :events, :title
    change_column_null :events, :node_id, false
  end
end