summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-15 01:41:34 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-15 04:23:09 +0200
commitd56155231814633e04f856d22646fea24ef97011 (patch)
tree9d5b6f8c32ee5b59783a2880388e7833278d1d87 /db
parent28a6999b55cbec555696df848d6e924aae3166ee (diff)
Add NodeAction: an append-only log of who did what to a nodeHEADmaster
node_id/page_id/user_id are lookup and ordering only -- all three nullify on delete, so an entry outlives its actor and its subject. Everything that must survive those deletions lives in a mandatory metadata jsonb written once at creation: the actor's username, the node's human-readable name (pinned to the default locale), and action-specific extras such as publish's title from/to. NodeAction.record! is the single constructor, so every entry gets the same baseline metadata without each call site re-implementing it. occurred_at is one field for live and backfilled entries alike; inferred_from distinguishes them -- nil means witnessed at the moment it happened, populated names how a backfilled entry was estimated. Instrumented so far: publish (crediting the actual publisher, threaded through from the controller -- previously nobody had the act of publishing recorded anywhere), revert's discard_autosave and destroy_draft branches, and translation destroy. publish_draft! now runs in a transaction so the promotion and its log entry land together. The remaining verbs follow once this mechanism has proven itself.
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20260714233414_create_node_actions.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/db/migrate/20260714233414_create_node_actions.rb b/db/migrate/20260714233414_create_node_actions.rb
new file mode 100644
index 0000000..6c18285
--- /dev/null
+++ b/db/migrate/20260714233414_create_node_actions.rb
@@ -0,0 +1,19 @@
1class CreateNodeActions < ActiveRecord::Migration[8.1]
2 def change
3 create_table :node_actions do |t|
4 t.references :node, foreign_key: { on_delete: :nullify }
5 t.references :page, foreign_key: { on_delete: :nullify }
6 t.references :user, foreign_key: { on_delete: :nullify }
7 t.string :action, null: false
8 t.string :locale
9 t.string :inferred_from
10 t.jsonb :metadata, null: false
11 t.datetime :occurred_at, null: false
12
13 t.timestamps
14 end
15
16 add_index :node_actions, [:node_id, :occurred_at]
17 add_index :node_actions, :action
18 end
19end