internal/store/migrations/0064_audit_chain.up.sql

v1.42.0
gitbay/internal/store/migrations/0064_audit_chain.up.sql history · blame · raw

8 lines · 533 bytes

1-- Each row carries the hash of the row before it. actor_ref is the actor
2-- id as written: actor_id is set to NULL when the account is deleted,
3-- and the hash must not change with it. Rows written before this
4-- migration keep an empty hash; the chain starts after them.
5ALTER TABLE audit_log ADD COLUMN actor_ref INTEGER NOT NULL DEFAULT 0;
6ALTER TABLE audit_log ADD COLUMN prev_hash TEXT NOT NULL DEFAULT '';
7ALTER TABLE audit_log ADD COLUMN hash TEXT NOT NULL DEFAULT '';
8UPDATE audit_log SET actor_ref = COALESCE(actor_id, 0);