Add sql script to generate tables
This commit is contained in:
18
database/001_create_tables.sql
Normal file
18
database/001_create_tables.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
CREATE TABLE
|
||||
users (id SERIAL PRIMARY KEY, name VARCHAR(255) NOT NULL);
|
||||
|
||||
CREATE TABLE
|
||||
workouts (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW ()
|
||||
);
|
||||
|
||||
CREATE TABLE
|
||||
cadence_readings (
|
||||
id SERIAL PRIMARY KEY,
|
||||
workout_id INTEGER NOT NULL REFERENCES workouts (id) ON DELETE CASCADE,
|
||||
created_at TIMESTAMP NOT NULL,
|
||||
rpm INTEGER NOT NULL,
|
||||
CONSTRAINT unique_cadence_reading_per_workout_time UNIQUE (workout_id, created_at)
|
||||
);
|
||||
Reference in New Issue
Block a user