Skip to content

Commit

Permalink
Start setting up migrations and writing initial SQL
Browse files Browse the repository at this point in the history
Will most likely use SQLite, though the script has not been verified
yet.
  • Loading branch information
arnavb committed Jun 11, 2024
1 parent e24d445 commit e0ce5ee
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Migrations/Migrations.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Data.Sqlite" Version="8.0.6" />
</ItemGroup>

</Project>
4 changes: 4 additions & 0 deletions Migrations/Program.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[<EntryPoint>]
let main args =
let connectionString = ""
0
49 changes: 49 additions & 0 deletions Migrations/Scripts/001_Create_Tables.sql
Original file line number Diff line number Diff line change
@@ -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),
);

0 comments on commit e0ce5ee

Please sign in to comment.