diff --git a/db/migrations/000001_init_schema.down.sql b/db/migrations/000001_init_schema.down.sql index dccb530..cf344b8 100644 --- a/db/migrations/000001_init_schema.down.sql +++ b/db/migrations/000001_init_schema.down.sql @@ -1,8 +1,14 @@ DROP TABLE IF EXISTS location_images; +DROP TABLE IF EXISTS client_ips; +DROP TABLE IF EXISTS user_reports; DROP TABLE IF EXISTS reviews; DROP TABLE IF EXISTS locations; DROP TABLE IF EXISTS regencies; DROP TABLE IF EXISTS provinces; DROP TABLE IF EXISTS regions; DROP TABLE IF EXISTS tags; -DROP TABLE IF EXISTS users; \ No newline at end of file +DROP TABLE IF EXISTS users; + + +DROP TYPE IF EXISTS user_reports_type; +DROP TYPE IF EXISTS comment_type; \ No newline at end of file diff --git a/db/migrations/000001_init_schema.up.sql b/db/migrations/000001_init_schema.up.sql index 4fb845d..8845a81 100644 --- a/db/migrations/000001_init_schema.up.sql +++ b/db/migrations/000001_init_schema.up.sql @@ -1,20 +1,54 @@ - CREATE TABLE users( - "id" serial primary key not null, - "email" varchar unique, - "username" varchar unique, - "password" varchar, - "avatar_picture" varchar, - "google_sign_in_payload" varchar, - "banned_at" timestamp, - "banned_until" timestamp, - "is_admin" boolean, - "is_critics" boolean, - "is_verified" boolean, - "ipv4_address" varchar(15) not null, - "social_media" jsonb, - "created_at" timestamp default(now()), - "updated_at" timestamp default(now()) - ); +CREATE TABLE users( + "id" serial primary key not null, + "email" varchar unique, + "username" varchar unique, + "password" varchar, + "avatar_picture" varchar, + "google_sign_in_payload" varchar, + "banned_at" timestamp, + "banned_until" timestamp, + "ban_reason" varchar, + "is_permaban" boolean, + "is_admin" boolean, + "is_critics" boolean, + "is_verified" boolean, + "social_media" jsonb, + "created_at" timestamp default(now()), + "updated_at" timestamp default(now()) +); + +CREATE TABLE client_ips( + "id" serial primary key not null, + "ipv4" varchar(15) not null, + "ipv6" varchar(40), + "banned_at" timestamp, + "banned_until" timestamp, + "reason" varchar, + "is_permaban" boolean, + "created_at" timestamp default(now()), + "updated_at" timestamp default(now()) +); + + +CREATE TYPE user_reports_type as ENUM( + 'comments', + 'reviews', + 'locations', + 'users', + 'stories' +); + +CREATE TABLE user_reports( + "id" serial primary key not null, + "message" text not null, + "date" timestamp not null, + "report_target" integer not null, + "report_type" user_reports_type not null, + "submitted_by" integer references "users"("id") not null, + "created_at" timestamp default(now()), + "updated_at" timestamp default(now()) +); + CREATE TABLE regions( "id" serial primary key not null, @@ -80,5 +114,21 @@ CREATE TABLE reviews ( "location_id" integer references "locations"("id") not null, "created_at" timestamp default(now()), "updated_at" timestamp default(now()) +); +CREATE TYPE comment_type AS ENUM( + 'stories', + 'news', + 'reviews' +); + +CREATE TABLE comments( + "id" serial primary key not null, + "submitted_by" integer not null, + "comment_on" integer not null, + "comment_type" comment_type not null, + "reply_to" integer, + "is_hide" boolean, + "created_at" timestamp default(now()), + "updated_at" timestamp default(now()) ); \ No newline at end of file