-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start setting up PostgreSQL based migrations.
SQLite is powerful, but the client-server architecture and multiple of types / functions / utilities available in PostgreSQL are undeniably useful.
- Loading branch information
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
CREATE TABLE bot_user | ||
( | ||
id SERIAL PRIMARY KEY, | ||
discord_id VARCHAR(64) UNIQUE NOT NULL | ||
); | ||
|
||
CREATE TYPE exercise_type as ENUM ('set', 'speed', 'time'); | ||
|
||
CREATE TABLE exercise | ||
( | ||
id SERIAL PRIMARY KEY, | ||
name VARCHAR(100) NOT NULL, | ||
type exercise_type NOT NULL, | ||
bot_user_id INT NOT NULL REFERENCES bot_user (id) | ||
); | ||
|
||
CREATE TABLE | ||
exercise_log | ||
( | ||
id SERIAL PRIMARY KEY, | ||
exercise_id INT NOT NULL REFERENCES exercise (id) | ||
); | ||
|
||
CREATE TABLE | ||
all_set_detail | ||
( | ||
id INT PRIMARY KEY REFERENCES exercise_log (id) | ||
); | ||
|
||
CREATE TABLE | ||
set_exercise_detail | ||
( | ||
id SERIAL PRIMARY KEY, | ||
reps INT NOT NULL, | ||
weight INT NOT NULL, | ||
is_warmup BOOLEAN NOT NULL, | ||
all_set_detail_id INT NOT NULL REFERENCES all_set_detail (id) | ||
); | ||
|
||
CREATE TABLE | ||
speed_exercise_detail | ||
( | ||
id INT PRIMARY KEY REFERENCES exercise_log (id), | ||
duration_sec INT NOT NULL, | ||
distance_miles REAL NOT NULL, | ||
exercise_log_id INT NOT NULL | ||
); | ||
|
||
CREATE TABLE | ||
time_exercise_details | ||
( | ||
id INT PRIMARY KEY REFERENCES exercise_log (id), | ||
duration_sec INT NOT NULL, | ||
exercise_log_id INT NOT NULL | ||
); |