-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sql
More file actions
24 lines (21 loc) · 718 Bytes
/
init.sql
File metadata and controls
24 lines (21 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-- Initialize database schema
CREATE TABLE IF NOT EXISTS workouts (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
description TEXT,
duration_minutes INTEGER,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS exercises (
id SERIAL PRIMARY KEY,
workout_id INTEGER REFERENCES workouts(id) ON DELETE CASCADE,
name VARCHAR(255) NOT NULL,
sets INTEGER,
reps INTEGER,
weight DECIMAL(10, 2),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Create indexes
CREATE INDEX idx_workouts_created_at ON workouts(created_at DESC);
CREATE INDEX idx_exercises_workout_id ON exercises(workout_id);