Add more db shite
This commit is contained in:
@@ -7,6 +7,7 @@ CREATE TABLE IF NOT EXISTS users (
|
||||
username TEXT NOT NULL UNIQUE,
|
||||
pw_hash TEXT NOT NULL,
|
||||
pw_salt TEXT NOT NULL,
|
||||
pfp_id BIGINT NOT NULL
|
||||
pfp_id BIGINT NOT NULL,
|
||||
rank_id BIGINT NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
CREATE TABLE IF NOT EXISTS sessions (
|
||||
user_id BIGINT NOT NULL,
|
||||
session_key TEXT NOT NULL UNIQUE,
|
||||
expires BIGINT NOT NULL
|
||||
expires BIGINT NOT NULL,
|
||||
CONSTRAINT fk_user FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
)
|
||||
|
||||
1
migrations/20250913111557_ranks.down.sql
Normal file
1
migrations/20250913111557_ranks.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS ranks;
|
||||
7
migrations/20250913111557_ranks.up.sql
Normal file
7
migrations/20250913111557_ranks.up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS ranks (
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
modified_at BIGINT NOT NULL
|
||||
);
|
||||
1
migrations/20250913111613_awards.down.sql
Normal file
1
migrations/20250913111613_awards.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS awards;
|
||||
7
migrations/20250913111613_awards.up.sql
Normal file
7
migrations/20250913111613_awards.up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS awards (
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
modified_at BIGINT NOT NULL
|
||||
);
|
||||
1
migrations/20250913111614_trainings.down.sql
Normal file
1
migrations/20250913111614_trainings.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS trainings;
|
||||
7
migrations/20250913111614_trainings.up.sql
Normal file
7
migrations/20250913111614_trainings.up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS trainings (
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
modified_at BIGINT NOT NULL
|
||||
);
|
||||
1
migrations/20250913111615_missions.down.sql
Normal file
1
migrations/20250913111615_missions.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS missions;
|
||||
7
migrations/20250913111615_missions.up.sql
Normal file
7
migrations/20250913111615_missions.up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS missions (
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
modified_at BIGINT NOT NULL
|
||||
);
|
||||
1
migrations/20250913111617_qualifications.down.sql
Normal file
1
migrations/20250913111617_qualifications.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS qualifications;
|
||||
7
migrations/20250913111617_qualifications.up.sql
Normal file
7
migrations/20250913111617_qualifications.up.sql
Normal file
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE IF NOT EXISTS qualifications (
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
modified_at BIGINT NOT NULL
|
||||
);
|
||||
1
migrations/20250913111736_records_ranks.down.sql
Normal file
1
migrations/20250913111736_records_ranks.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS record_ranks;
|
||||
11
migrations/20250913111736_records_ranks.up.sql
Normal file
11
migrations/20250913111736_records_ranks.up.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS records_ranks (
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL,
|
||||
user_id BIGINT NOT NULL,
|
||||
rank_id BIGINT NOT NULL,
|
||||
author_id BIGINT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
|
||||
CONSTRAINT fk_user FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_author FOREIGN KEY(author_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
CONSTRAINT fk_rank FOREIGN KEY (rank_id) REFERENCES ranks(id) ON DELETE CASCADE
|
||||
);
|
||||
1
migrations/20250913111748_records_awards.down.sql
Normal file
1
migrations/20250913111748_records_awards.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS record_awards;
|
||||
11
migrations/20250913111748_records_awards.up.sql
Normal file
11
migrations/20250913111748_records_awards.up.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS records_awards (
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL,
|
||||
user_id BIGINT NOT NULL,
|
||||
award_id BIGINT NOT NULL,
|
||||
author_id BIGINT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
|
||||
CONSTRAINT fk_user FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_author FOREIGN KEY(author_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
CONSTRAINT fk_award FOREIGN KEY (award_id) REFERENCES awards(id) ON DELETE CASCADE
|
||||
);
|
||||
1
migrations/20250913111802_records_training.down.sql
Normal file
1
migrations/20250913111802_records_training.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS record_training;
|
||||
11
migrations/20250913111802_records_training.up.sql
Normal file
11
migrations/20250913111802_records_training.up.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS records_trainings (
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL,
|
||||
user_id BIGINT NOT NULL,
|
||||
training_id BIGINT NOT NULL,
|
||||
author_id BIGINT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
|
||||
CONSTRAINT fk_user FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_author FOREIGN KEY(author_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
CONSTRAINT fk_training FOREIGN KEY (training_id) REFERENCES trainings(id) ON DELETE CASCADE
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS record_qualifications;
|
||||
11
migrations/20250913111810_records_qualifications.up.sql
Normal file
11
migrations/20250913111810_records_qualifications.up.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS records_qualifications (
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL,
|
||||
user_id BIGINT NOT NULL,
|
||||
qualification_id BIGINT NOT NULL,
|
||||
author_id BIGINT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
|
||||
CONSTRAINT fk_user FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_author FOREIGN KEY(author_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
CONSTRAINT fk_qualification FOREIGN KEY (qualification_id) REFERENCES qualifications(id) ON DELETE CASCADE
|
||||
);
|
||||
1
migrations/20250913112041_records_missions.down.sql
Normal file
1
migrations/20250913112041_records_missions.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS records_missions;
|
||||
11
migrations/20250913112041_records_missions.up.sql
Normal file
11
migrations/20250913112041_records_missions.up.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
CREATE TABLE IF NOT EXISTS records_missions (
|
||||
id BIGSERIAL PRIMARY KEY NOT NULL,
|
||||
user_id BIGINT NOT NULL,
|
||||
mission_id BIGINT NOT NULL,
|
||||
author_id BIGINT NOT NULL,
|
||||
created_at BIGINT NOT NULL,
|
||||
|
||||
CONSTRAINT fk_user FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
CONSTRAINT fk_author FOREIGN KEY(author_id) REFERENCES users(id) ON DELETE SET NULL,
|
||||
CONSTRAINT fk_mission FOREIGN KEY (mission_id) REFERENCES missions(id) ON DELETE CASCADE
|
||||
);
|
||||
Reference in New Issue
Block a user