You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bodytrack/db/schema/0002_stats.sql

23 lines
643 B

CREATE SCHEMA Stats;
CREATE TABLE Stats.Log (
id SERIAL PRIMARY KEY,
userId INT NOT NULL REFERENCES Accounts.Users(id),
logType LogType NOT NULL DEFAULT 'Weight',
value DECIMAL NOT NULL,
recordedTs TIMESTAMP NOT NULL DEFAULT NOW()
);
CREATE INDEX log_logType ON Stats.Log USING btree (logType);
CREATE TABLE Stats.LogGoal (
id SERIAL PRIMARY KEY,
userId INT NOT NULL REFERENCES Accounts.Users(id),
logType LogType NOT NULL,
value DECIMAL NOT NULL,
startTs TIMESTAMP NOT NULL DEFAULT NOW(),
endTs TIMESTAMP NOT NULL DEFAULT NOW()
);
CREATE INDEX log_userId ON Stats.LogGoal USING btree (userId);