54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { sqliteTable, text, integer, real } from "drizzle-orm/sqlite-core";
|
|
|
|
export const templates = sqliteTable("templates", {
|
|
id: text("id").primaryKey(),
|
|
name: text("name").notNull(),
|
|
description: text("description"),
|
|
poolLength: real("pool_length").notNull().default(25),
|
|
jsonData: text("json_data").notNull(),
|
|
isFavorite: integer("is_favorite", { mode: "boolean" }).notNull().default(false),
|
|
createdAt: text("created_at").notNull(),
|
|
});
|
|
|
|
export const workouts = sqliteTable("workouts", {
|
|
id: text("id").primaryKey(),
|
|
name: text("name"),
|
|
templateId: text("template_id"),
|
|
poolLength: real("pool_length").notNull().default(25),
|
|
startedAt: text("started_at").notNull(),
|
|
finishedAt: text("finished_at"),
|
|
totalDistance: integer("total_distance"),
|
|
totalDuration: real("total_duration"),
|
|
calories: real("calories"),
|
|
avgHeartRate: integer("avg_heart_rate"),
|
|
source: text("source").notNull().default("manual"),
|
|
});
|
|
|
|
export const sets = sqliteTable("sets", {
|
|
id: text("id").primaryKey(),
|
|
workoutId: text("workout_id")
|
|
.notNull()
|
|
.references(() => workouts.id),
|
|
position: integer("position").notNull(),
|
|
stroke: text("stroke").notNull(),
|
|
distancePerRep: integer("distance_per_rep").notNull(),
|
|
repCount: integer("rep_count").notNull(),
|
|
restType: text("rest_type").notNull().default("fixed_rest"),
|
|
restDuration: real("rest_duration").notNull().default(0),
|
|
targetTime: real("target_time"),
|
|
});
|
|
|
|
export const laps = sqliteTable("laps", {
|
|
id: text("id").primaryKey(),
|
|
workoutId: text("workout_id")
|
|
.notNull()
|
|
.references(() => workouts.id),
|
|
setPosition: integer("set_position").notNull(),
|
|
repNumber: integer("rep_number").notNull(),
|
|
distance: integer("distance").notNull(),
|
|
duration: real("duration").notNull(),
|
|
strokeCount: integer("stroke_count"),
|
|
heartRate: integer("heart_rate"),
|
|
swolf: real("swolf"),
|
|
});
|