26 lines
1.1 KiB
SQL
26 lines
1.1 KiB
SQL
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`); |