user, role, post db
This commit is contained in:
parent
20af44c357
commit
ee9015c1e3
15 changed files with 210 additions and 74 deletions
|
@ -1,3 +1,3 @@
|
|||
-- Add down migration script here
|
||||
DROP TABLE IF EXISTS "user";
|
||||
DROP TYPE IF EXISTS role;
|
||||
DROP TABLE IF EXISTS "role";
|
|
@ -1,12 +1,19 @@
|
|||
-- Add up migration script here
|
||||
DROP TYPE IF EXISTS role;
|
||||
CREATE TYPE role AS ENUM('Zero', 'Hero');
|
||||
CREATE TABLE IF NOT EXISTS "role"(
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL UNIQUE,
|
||||
name VARCHAR(16) NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
INSERT INTO "role"(id, name) VALUES (0, 'Ahmet Kaan Gümüş');
|
||||
INSERT INTO "role"(id, name) VALUES (1, 'Founder');
|
||||
INSERT INTO "role"(id, name) VALUES (2, 'Normal');
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "user"(
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
surname VARCHAR(255) NOT NULL,
|
||||
gender boolean NOT NULL,
|
||||
birth_date DATE NOT NULL,
|
||||
email VARCHAR(255) NOT NULL UNIQUE,
|
||||
role ROLE NOT NULL DEFAULT 'Zero'
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL UNIQUE,
|
||||
name VARCHAR(255) NOT NULL,
|
||||
surname VARCHAR(255) NOT NULL,
|
||||
gender boolean NOT NULL,
|
||||
birth_date DATE NOT NULL,
|
||||
email VARCHAR(255) NOT NULL UNIQUE,
|
||||
role_id BIGSERIAL NOT NULL REFERENCES "role"(id)
|
||||
);
|
2
migrations/20241204130431_create_post_table.down.sql
Normal file
2
migrations/20241204130431_create_post_table.down.sql
Normal file
|
@ -0,0 +1,2 @@
|
|||
-- Add down migration script here
|
||||
DROP TABLE IF EXISTS "post";
|
6
migrations/20241204130431_create_post_table.up.sql
Normal file
6
migrations/20241204130431_create_post_table.up.sql
Normal file
|
@ -0,0 +1,6 @@
|
|||
-- Add up migration script here
|
||||
CREATE TABLE "post"(
|
||||
creation_time TIMESTAMPTZ PRIMARY KEY UNIQUE NOT NULL,
|
||||
poster_id BIGSERIAL NOT NULL REFERENCES "user"(id),
|
||||
post VARCHAR NOT NULL UNIQUE
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue