CREATE TABLE `categories` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `name` text NOT NULL ); --> statement-breakpoint CREATE TABLE `comments` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `text` text NOT NULL, `author_id` integer NOT NULL, `post_id` integer NOT NULL, `createdAt` text DEFAULT (current_timestamp) NOT NULL, FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`post_id`) REFERENCES `posts`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `post_likes` ( `post_id` integer NOT NULL, `user_id` integer NOT NULL, PRIMARY KEY(`post_id`, `user_id`), FOREIGN KEY (`post_id`) REFERENCES `posts`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `posts` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `slug` text, `title` text NOT NULL, `content` text NOT NULL, `published` integer DEFAULT 0 NOT NULL, `author_id` integer NOT NULL, `category_id` integer, `createdAt` text DEFAULT (current_timestamp) NOT NULL, FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`category_id`) REFERENCES `categories`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `profile` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `user_id` integer NOT NULL, `bio` text, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `roles` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `name` text NOT NULL ); --> statement-breakpoint CREATE TABLE `user_roles` ( `user_id` integer NOT NULL, `role_id` integer NOT NULL, PRIMARY KEY(`role_id`, `user_id`), FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `users` ( `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, `username` text NOT NULL, `first_name` text, `last_name` text ); --> statement-breakpoint CREATE UNIQUE INDEX `categories_name_unique` ON `categories` (`name`);--> statement-breakpoint CREATE UNIQUE INDEX `posts_slug_unique` ON `posts` (`slug`);--> statement-breakpoint CREATE UNIQUE INDEX `roles_name_unique` ON `roles` (`name`);--> statement-breakpoint CREATE UNIQUE INDEX `users_username_unique` ON `users` (`username`);