CREATE TABLE `projects` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `name` text NOT NULL, `archived` integer DEFAULT false NOT NULL ); --> statement-breakpoint CREATE UNIQUE INDEX `projects_name_unique` ON `projects` (`name`);--> statement-breakpoint CREATE TABLE `routine_completions` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `routine_id` integer NOT NULL, `routine_version` integer NOT NULL, `done_at` text NOT NULL, `note` text, FOREIGN KEY (`routine_id`,`routine_version`) REFERENCES `routines`(`id`,`version`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `routines` ( `id` integer NOT NULL, `version` integer NOT NULL, `project_id` integer NOT NULL, `name` text NOT NULL, `frequency_days` integer NOT NULL, `archived` integer DEFAULT false NOT NULL, `created_at` text NOT NULL, PRIMARY KEY(`id`, `version`), FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON UPDATE no action ON DELETE cascade );