CREATE TABLE `group_members` ( `id` text PRIMARY KEY NOT NULL, `group_id` text NOT NULL, `user_id` text NOT NULL, `joined_at` text NOT NULL, FOREIGN KEY (`group_id`) REFERENCES `groups`(`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 `groups` ( `id` text PRIMARY KEY NOT NULL, `organization_id` text NOT NULL, `name` text NOT NULL, `description` text, `color` text, `created_at` text NOT NULL, FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `organization_members` ( `id` text PRIMARY KEY NOT NULL, `organization_id` text NOT NULL, `user_id` text NOT NULL, `role` text NOT NULL, `joined_at` text NOT NULL, FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`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 `organizations` ( `id` text PRIMARY KEY NOT NULL, `name` text NOT NULL, `slug` text NOT NULL, `type` text NOT NULL, `logo_url` text, `is_active` integer DEFAULT true NOT NULL, `created_at` text NOT NULL, `updated_at` text NOT NULL ); --> statement-breakpoint CREATE UNIQUE INDEX `organizations_slug_unique` ON `organizations` (`slug`);--> statement-breakpoint CREATE TABLE `project_members` ( `id` text PRIMARY KEY NOT NULL, `project_id` text NOT NULL, `user_id` text NOT NULL, `role` text NOT NULL, `assigned_at` text NOT NULL, FOREIGN KEY (`project_id`) REFERENCES `projects`(`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 `team_members` ( `id` text PRIMARY KEY NOT NULL, `team_id` text NOT NULL, `user_id` text NOT NULL, `joined_at` text NOT NULL, FOREIGN KEY (`team_id`) REFERENCES `teams`(`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 `teams` ( `id` text PRIMARY KEY NOT NULL, `organization_id` text NOT NULL, `name` text NOT NULL, `description` text, `created_at` text NOT NULL, FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `users` ( `id` text PRIMARY KEY NOT NULL, `email` text NOT NULL, `first_name` text, `last_name` text, `display_name` text, `avatar_url` text, `role` text DEFAULT 'office' NOT NULL, `is_active` integer DEFAULT true NOT NULL, `last_login_at` text, `created_at` text NOT NULL, `updated_at` text NOT NULL ); --> statement-breakpoint CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);--> statement-breakpoint ALTER TABLE `projects` ADD `organization_id` text REFERENCES organizations(id);