-- 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);