]> Untitled Git - lemmy.git/blobdiff - migrations/2019-04-07-003142_create_moderation_logs/up.sql
Adding SQL format checking via `pg_format` / pgFormatter (#3740)
[lemmy.git] / migrations / 2019-04-07-003142_create_moderation_logs / up.sql
index 3b320d810d70a3ba664767ecfd39088c9dc41ecb..718723c9fd6832506dc6466a974399a6f3d77bb6 100644 (file)
@@ -1,76 +1,76 @@
-create table mod_remove_post (
-  id serial primary key,
-  mod_user_id int references user_ on update cascade on delete cascade not null,
-  post_id int references post on update cascade on delete cascade not null,
-  reason text,
-  removed boolean default true,
-  when_ timestamp not null default now()
+CREATE TABLE mod_remove_post (
+    id serial PRIMARY KEY,
+    mod_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    reason text,
+    removed boolean DEFAULT TRUE,
+    when_ timestamp NOT NULL DEFAULT now()
 );
 
-create table mod_lock_post (
-  id serial primary key,
-  mod_user_id int references user_ on update cascade on delete cascade not null,
-  post_id int references post on update cascade on delete cascade not null,
-  locked boolean default true,
-  when_ timestamp not null default now()
+CREATE TABLE mod_lock_post (
+    id serial PRIMARY KEY,
+    mod_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    post_id int REFERENCES post ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    locked boolean DEFAULT TRUE,
+    when_ timestamp NOT NULL DEFAULT now()
 );
 
-create table mod_remove_comment (
-  id serial primary key,
-  mod_user_id int references user_ on update cascade on delete cascade not null,
-  comment_id int references comment on update cascade on delete cascade not null,
-  reason text,
-  removed boolean default true,
-  when_ timestamp not null default now()
+CREATE TABLE mod_remove_comment (
+    id serial PRIMARY KEY,
+    mod_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    comment_id int REFERENCES COMMENT ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    reason text,
+    removed boolean DEFAULT TRUE,
+    when_ timestamp NOT NULL DEFAULT now()
 );
 
-create table mod_remove_community (
-  id serial primary key,
-  mod_user_id int references user_ on update cascade on delete cascade not null,
-  community_id int references community on update cascade on delete cascade not null,
-  reason text,
-  removed boolean default true,
-  expires timestamp,
-  when_ timestamp not null default now()
+CREATE TABLE mod_remove_community (
+    id serial PRIMARY KEY,
+    mod_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    community_id int REFERENCES community ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    reason text,
+    removed boolean DEFAULT TRUE,
+    expires timestamp,
+    when_ timestamp NOT NULL DEFAULT now()
 );
 
 -- TODO make sure you can't ban other mods
-create table mod_ban_from_community (
-  id serial primary key,
-  mod_user_id int references user_ on update cascade on delete cascade not null,
-  other_user_id int references user_ on update cascade on delete cascade not null,
-  community_id int references community on update cascade on delete cascade not null,
-  reason text,
-  banned boolean default true,
-  expires timestamp,
-  when_ timestamp not null default now()
+CREATE TABLE mod_ban_from_community (
+    id serial PRIMARY KEY,
+    mod_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    other_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    community_id int REFERENCES community ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    reason text,
+    banned boolean DEFAULT TRUE,
+    expires timestamp,
+    when_ timestamp NOT NULL DEFAULT now()
 );
 
-create table mod_ban (
-  id serial primary key,
-  mod_user_id int references user_ on update cascade on delete cascade not null,
-  other_user_id int references user_ on update cascade on delete cascade not null,
-  reason text,
-  banned boolean default true,
-  expires timestamp,
-  when_ timestamp not null default now()
+CREATE TABLE mod_ban (
+    id serial PRIMARY KEY,
+    mod_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    other_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    reason text,
+    banned boolean DEFAULT TRUE,
+    expires timestamp,
+    when_ timestamp NOT NULL DEFAULT now()
 );
 
-create table mod_add_community (
-  id serial primary key,
-  mod_user_id int references user_ on update cascade on delete cascade not null,
-  other_user_id int references user_ on update cascade on delete cascade not null,
-  community_id int references community on update cascade on delete cascade not null,
-  removed boolean default false,
-  when_ timestamp not null default now()
+CREATE TABLE mod_add_community (
+    id serial PRIMARY KEY,
+    mod_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    other_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    community_id int REFERENCES community ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    removed boolean DEFAULT FALSE,
+    when_ timestamp NOT NULL DEFAULT now()
 );
 
 -- When removed is false that means kicked
-create table mod_add (
-  id serial primary key,
-  mod_user_id int references user_ on update cascade on delete cascade not null,
-  other_user_id int references user_ on update cascade on delete cascade not null,
-  removed boolean default false,
-  when_ timestamp not null default now()
+CREATE TABLE mod_add (
+    id serial PRIMARY KEY,
+    mod_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    other_user_id int REFERENCES user_ ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
+    removed boolean DEFAULT FALSE,
+    when_ timestamp NOT NULL DEFAULT now()
 );