From e0ce5ee28ad3f099ee98c12146def4d65e3c3bb1 Mon Sep 17 00:00:00 2001 From: Arnav Borborah Date: Mon, 10 Jun 2024 22:56:00 -0400 Subject: [PATCH] Start setting up migrations and writing initial SQL Will most likely use SQLite, though the script has not been verified yet. --- Migrations/Migrations.fsproj | 16 ++++++++ Migrations/Program.fs | 4 ++ Migrations/Scripts/001_Create_Tables.sql | 49 ++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 Migrations/Migrations.fsproj create mode 100644 Migrations/Program.fs create mode 100644 Migrations/Scripts/001_Create_Tables.sql diff --git a/Migrations/Migrations.fsproj b/Migrations/Migrations.fsproj new file mode 100644 index 0000000..fe9601c --- /dev/null +++ b/Migrations/Migrations.fsproj @@ -0,0 +1,16 @@ + + + + Exe + net8.0 + + + + + + + + + + + diff --git a/Migrations/Program.fs b/Migrations/Program.fs new file mode 100644 index 0000000..c06c1e7 --- /dev/null +++ b/Migrations/Program.fs @@ -0,0 +1,4 @@ +[] +let main args = + let connectionString = "" + 0 diff --git a/Migrations/Scripts/001_Create_Tables.sql b/Migrations/Scripts/001_Create_Tables.sql new file mode 100644 index 0000000..8c649de --- /dev/null +++ b/Migrations/Scripts/001_Create_Tables.sql @@ -0,0 +1,49 @@ +PRAGMA foreign_keys = ON; + +CREATE TABLE + user (id INT PRIMARY KEY, discord_id TEXT); + +CREATE TABLE + exercise ( + id INT PRIMARY KEY, + name TEXT NOT NULL, + type TEXT NOT NULL, + user_id INT NOT NULL, + FOREIGN KEY (user_id) REFERENCES user (id) + ); + +CREATE TABLE + exercise_log (id INT PRIMARY KEY); + +CREATE TABLE + all_set_details ( + id INT PRIMARY KEY, + exercise_log_id INT NOT NULL, + FOREIGN KEY (exercise_log_id) REFERENCES exercise_log (id) + ); + +CREATE TABLE + set_exercise_details ( + id INT PRIMARY KEY, + reps INT NOT NULL, + weight INT NOT NULL, + is_warmup BOOLEAN NOT NULL, + all_set_details_id INT NOT NULL, + FOREIGN KEY (all_set_details_id) REFERENCES all_set_details (id) + ); + +CREATE TABLE + speed_exercise_details ( + id INT PRIMARY KEY, + duration_sec INT NOT NULL distance_miles REAL NOT NULL, + exercise_log_id INT NOT NULL, + FOREIGN KEY (exercise_log_id) REFERENCES exercise_log (id) + ); + +CREATE TABLE + time_exercise_details ( + id INT PRIMARY KEY, + duration_sec INT NOT NULL, + exercise_log_id INT NOT NULL, + FOREIGN KEY (exercise_log_id) REFERENCES exercise_log (id), + ); \ No newline at end of file