CREATE TABLE `entries` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `date` text NOT NULL, `text` text NOT NULL, `mood` integer, `rough_day` integer DEFAULT 0 NOT NULL, `created_at` integer NOT NULL, `updated_at` integer NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `entry_tags` ( `entry_id` text NOT NULL, `tag_id` text NOT NULL, PRIMARY KEY(`entry_id`, `tag_id`), FOREIGN KEY (`entry_id`) REFERENCES `entries`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`tag_id`) REFERENCES `tags`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `sessions` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `expires_at` integer NOT NULL, `created_at` integer NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `tags` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `name` text NOT NULL, `created_at` integer NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `users` ( `id` text PRIMARY KEY NOT NULL, `email` text NOT NULL, `password_hash` text NOT NULL, `name` text, `created_at` integer NOT NULL ); --> statement-breakpoint CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);