audit log basic db implementation
This commit is contained in:
parent
e80a6753a5
commit
aa144b719a
4 changed files with 62 additions and 8 deletions
|
@ -2,6 +2,15 @@
|
|||
-- Tables
|
||||
--
|
||||
|
||||
-- Audit logs
|
||||
CREATE TABLE arimelody.auditlog (
|
||||
id UUID DEFAULT gen_random_uuid(),
|
||||
level int NOT NULL DEFAULT 0,
|
||||
type TEXT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
-- Accounts
|
||||
CREATE TABLE arimelody.account (
|
||||
id UUID DEFAULT gen_random_uuid(),
|
||||
|
@ -9,7 +18,7 @@ CREATE TABLE arimelody.account (
|
|||
password TEXT NOT NULL,
|
||||
email TEXT,
|
||||
avatar_url TEXT,
|
||||
created_at TIMESTAMP DEFAULT current_timestamp
|
||||
created_at TIMESTAMP NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
ALTER TABLE arimelody.account ADD CONSTRAINT account_pk PRIMARY KEY (id);
|
||||
|
||||
|
@ -74,7 +83,8 @@ CREATE TABLE arimelody.musicrelease (
|
|||
buyname text,
|
||||
buylink text,
|
||||
copyright text,
|
||||
copyrightURL text
|
||||
copyrightURL text,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT current_timestamp,
|
||||
);
|
||||
ALTER TABLE arimelody.musicrelease ADD CONSTRAINT musicrelease_pk PRIMARY KEY (id);
|
||||
|
||||
|
|
12
schema-migration/002-audit-logs.sql
Normal file
12
schema-migration/002-audit-logs.sql
Normal file
|
@ -0,0 +1,12 @@
|
|||
-- Audit logs
|
||||
CREATE TABLE arimelody.auditlog (
|
||||
id UUID DEFAULT gen_random_uuid(),
|
||||
level int NOT NULL DEFAULT 0,
|
||||
type TEXT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT current_timestamp
|
||||
);
|
||||
|
||||
-- Need moar timestamps
|
||||
ALTER TABLE arimelody.musicrelease ADD COLUMN created_at TIMESTAMP NOT NULL DEFAULT current_timestamp;
|
||||
ALTER TABLE arimelody.account ALTER COLUMN created_at SET NOT NULL;
|
Loading…
Add table
Add a link
Reference in a new issue