cacert-boardvoting/internal/migrations/2022060101_add_audit_table.up.sql
Jan Dittberner 5efc57d2c3 Implement user deletion
- add audit logging for user changes
- refactor model errors into functions
- implement user delete form and submit handlers
2022-06-01 18:57:38 +02:00

18 lines
No EOL
875 B
SQL

-- add an audit table to track changes to users
CREATE TABLE audit
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
-- copied authenticated user name to keep the information when the admin is locked/deleted later
user_name VARCHAR(255) NOT NULL,
-- copied authenticated user email address to keep the information when the admin is locked/deleted later
user_address VARCHAR(255) NOT NULL,
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
-- an enum (in code) value to specify the action. Stored as text to be flexible for future changes
change TEXT NOT NULL,
-- reasoning for the change specified by the user
reasoning TEXT NOT NULL,
-- additional information about the change in an application specific json format
details TEXT
);
CREATE INDEX audit_change_idx ON audit (change);