-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupabase_schema.sql
More file actions
52 lines (46 loc) · 1.75 KB
/
supabase_schema.sql
File metadata and controls
52 lines (46 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
-- Enable UUID generation
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-- This is the schema for the BalanceBuddy app.
-- Create the 'users' table
CREATE TABLE IF NOT EXISTS users (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
email VARCHAR(255) UNIQUE NOT NULL,
name VARCHAR(255),
age INTEGER,
height INTEGER, -- Height in cm
weight INTEGER, -- Weight in kg
created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now())
);
-- Create the 'exercises' table
CREATE TABLE IF NOT EXISTS exercises (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name VARCHAR(255) NOT NULL,
description TEXT,
video_url VARCHAR(255),
created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now())
);
-- Create the 'workouts' table
CREATE TABLE IF NOT EXISTS workouts (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID REFERENCES users(id),
name VARCHAR(255) NOT NULL,
description TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now())
);
-- Create the 'workout_exercises' table to link workouts to exercises
CREATE TABLE IF NOT EXISTS workout_exercises (
workout_id UUID REFERENCES workouts(id) ON DELETE CASCADE,
exercise_id UUID REFERENCES exercises(id) ON DELETE CASCADE,
PRIMARY KEY (workout_id, exercise_id)
);
-- Create the 'progress_tracking' table
CREATE TABLE IF NOT EXISTS progress_tracking (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
workout_id UUID REFERENCES workouts(id) ON DELETE CASCADE,
date DATE NOT NULL,
duration INTEGER, -- Duration in minutes
calories_burned INTEGER,
notes TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT timezone('utc'::text, now())
);