summaryrefslogtreecommitdiff
path: root/db/migrate/20260714233414_create_node_actions.rb
blob: 6c18285e8056ecd46021eee705c44ccbcfc93818 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class CreateNodeActions < ActiveRecord::Migration[8.1]
  def change
    create_table :node_actions do |t|
      t.references :node, foreign_key: { on_delete: :nullify }
      t.references :page, foreign_key: { on_delete: :nullify }
      t.references :user, foreign_key: { on_delete: :nullify }
      t.string   :action, null: false
      t.string   :locale
      t.string   :inferred_from
      t.jsonb    :metadata, null: false
      t.datetime :occurred_at, null: false

      t.timestamps
    end

    add_index :node_actions, [:node_id, :occurred_at]
    add_index :node_actions, :action
  end
end