feat(api): add activities + work_sessions domain schema and shared contracts

This commit is contained in:
Bas van Rossem
2026-06-17 15:29:14 +02:00
parent 40a2512dfd
commit 57809985fd
6 changed files with 732 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
CREATE TABLE `activities` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`name` text NOT NULL,
`insole_types` text DEFAULT '["Kurk","Berk","3D"]' NOT NULL,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL
);
--> statement-breakpoint
CREATE TABLE `work_sessions` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`user_id` text NOT NULL,
`activity_id` integer NOT NULL,
`insole_type` text,
`pair_count` integer DEFAULT 2 NOT NULL,
`start_time` integer NOT NULL,
`end_time` integer,
`duration_seconds` integer,
`status` text DEFAULT 'active' NOT NULL,
`source` text DEFAULT 'app' NOT NULL,
`notes` text,
`created_at` integer DEFAULT (cast(unixepoch('subsecond') * 1000 as integer)) NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`activity_id`) REFERENCES `activities`(`id`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE INDEX `work_sessions_userId_idx` ON `work_sessions` (`user_id`);--> statement-breakpoint
CREATE INDEX `work_sessions_startTime_idx` ON `work_sessions` (`start_time`);