add migration for comments

This commit is contained in:
nochill 2023-09-11 12:20:10 +07:00
parent ed85ece58a
commit ed608f170a
2 changed files with 74 additions and 18 deletions

View File

@ -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;
DROP TABLE IF EXISTS users;
DROP TYPE IF EXISTS user_reports_type;
DROP TYPE IF EXISTS comment_type;

View File

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