CREATE TABLE `email_verification_tokens` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `token` text NOT NULL, `expires_at` text NOT NULL, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE UNIQUE INDEX `email_verification_tokens_token_unique` ON `email_verification_tokens` (`token`);--> statement-breakpoint CREATE TABLE `gpg_keys` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `name` text NOT NULL, `key_id` text NOT NULL, `public_key` text NOT NULL, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `oauth_accounts` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `provider` text NOT NULL, `provider_account_id` text NOT NULL, `access_token` text, `refresh_token` text, `expires_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `password_reset_tokens` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `token` text NOT NULL, `expires_at` text NOT NULL, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE UNIQUE INDEX `password_reset_tokens_token_unique` ON `password_reset_tokens` (`token`);--> statement-breakpoint CREATE TABLE `personal_access_tokens` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `name` text NOT NULL, `token` text NOT NULL, `expires_at` text, `last_used_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE UNIQUE INDEX `personal_access_tokens_token_unique` ON `personal_access_tokens` (`token`);--> statement-breakpoint CREATE TABLE `sessions` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `token` text NOT NULL, `user_agent` text, `ip_address` text, `expires_at` text NOT NULL, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE UNIQUE INDEX `sessions_token_unique` ON `sessions` (`token`);--> statement-breakpoint CREATE TABLE `ssh_keys` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `title` text NOT NULL, `fingerprint` text NOT NULL, `public_key` text NOT NULL, `key_type` text NOT NULL, `last_used_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE UNIQUE INDEX `ssh_keys_fingerprint_unique` ON `ssh_keys` (`fingerprint`);--> statement-breakpoint CREATE TABLE `users` ( `id` text PRIMARY KEY NOT NULL, `username` text NOT NULL, `email` text NOT NULL, `password_hash` text, `display_name` text, `bio` text, `avatar_url` text, `location` text, `website` text, `company` text, `is_admin` integer DEFAULT false, `is_active` integer DEFAULT true, `email_verified` integer DEFAULT false, `two_factor_enabled` integer DEFAULT false, `two_factor_secret` text, `last_login_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL ); --> statement-breakpoint CREATE UNIQUE INDEX `users_username_unique` ON `users` (`username`);--> statement-breakpoint CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);--> statement-breakpoint CREATE TABLE `branches` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `name` text NOT NULL, `commit_sha` text NOT NULL, `is_protected` integer DEFAULT false, `is_default` integer DEFAULT false, `protection_rules` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `commits` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `sha` text NOT NULL, `message` text NOT NULL, `author_name` text NOT NULL, `author_email` text NOT NULL, `author_date` text NOT NULL, `committer_name` text NOT NULL, `committer_email` text NOT NULL, `committer_date` text NOT NULL, `parent_shas` text, `tree_sha` text, `user_id` text, `stats` text, `signature` text, `is_verified` integer DEFAULT false, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `releases` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `tag_id` text, `name` text NOT NULL, `body` text, `is_draft` integer DEFAULT false, `is_prerelease` integer DEFAULT false, `author_id` text, `assets` text, `download_count` integer DEFAULT 0, `published_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`tag_id`) REFERENCES `tags`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `repositories` ( `id` text PRIMARY KEY NOT NULL, `name` text NOT NULL, `slug` text NOT NULL, `description` text, `owner_id` text NOT NULL, `owner_type` text DEFAULT 'user' NOT NULL, `visibility` text DEFAULT 'public' NOT NULL, `default_branch` text DEFAULT 'main' NOT NULL, `disk_path` text NOT NULL, `ssh_clone_url` text, `http_clone_url` text, `star_count` integer DEFAULT 0, `fork_count` integer DEFAULT 0, `watch_count` integer DEFAULT 0, `open_issue_count` integer DEFAULT 0, `open_pr_count` integer DEFAULT 0, `size` integer DEFAULT 0, `is_fork` integer DEFAULT false, `forked_from_id` text, `is_archived` integer DEFAULT false, `is_mirror` integer DEFAULT false, `mirror_url` text, `has_issues` integer DEFAULT true, `has_wiki` integer DEFAULT true, `has_actions` integer DEFAULT true, `allow_forking` integer DEFAULT true, `license_type` text, `topics` text, `language` text, `languages` text, `last_activity_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`owner_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`forked_from_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `repository_collaborators` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `user_id` text NOT NULL, `role` text DEFAULT 'developer' NOT NULL, `added_by_id` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`added_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `repository_stars` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `user_id` text NOT NULL, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`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 `repository_watchers` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `user_id` text NOT NULL, `watch_level` text DEFAULT 'watching' NOT NULL, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`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 `tags` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `name` text NOT NULL, `commit_sha` text NOT NULL, `message` text, `tagger_name` text, `tagger_email` text, `tagged_at` text, `is_release` integer DEFAULT false, `release_id` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `webhooks` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `url` text NOT NULL, `secret` text, `events` text NOT NULL, `is_active` integer DEFAULT true, `last_delivery_at` text, `last_delivery_status` integer, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `issue_assignees` ( `id` text PRIMARY KEY NOT NULL, `issue_id` text NOT NULL, `user_id` text NOT NULL, `assigned_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`issue_id`) REFERENCES `issues`(`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 `issue_comments` ( `id` text PRIMARY KEY NOT NULL, `issue_id` text NOT NULL, `author_id` text NOT NULL, `body` text NOT NULL, `reactions` text, `is_edited` integer DEFAULT false, `edited_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`issue_id`) REFERENCES `issues`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `issue_labels` ( `id` text PRIMARY KEY NOT NULL, `issue_id` text NOT NULL, `label_id` text NOT NULL, FOREIGN KEY (`issue_id`) REFERENCES `issues`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`label_id`) REFERENCES `labels`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `issue_subscribers` ( `id` text PRIMARY KEY NOT NULL, `issue_id` text NOT NULL, `user_id` text NOT NULL, `subscribed_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`issue_id`) REFERENCES `issues`(`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 `issues` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `number` integer NOT NULL, `title` text NOT NULL, `body` text, `state` text DEFAULT 'open' NOT NULL, `author_id` text NOT NULL, `assignee_id` text, `milestone_id` text, `is_pinned` integer DEFAULT false, `is_locked` integer DEFAULT false, `lock_reason` text, `comment_count` integer DEFAULT 0, `reactions` text, `closed_at` text, `closed_by_id` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`assignee_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`milestone_id`) REFERENCES `milestones`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`closed_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `labels` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `name` text NOT NULL, `color` text DEFAULT '#6b7280' NOT NULL, `description` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `milestones` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `title` text NOT NULL, `description` text, `state` text DEFAULT 'open' NOT NULL, `due_date` text, `open_issue_count` integer DEFAULT 0, `closed_issue_count` integer DEFAULT 0, `closed_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `pull_request_assignees` ( `id` text PRIMARY KEY NOT NULL, `pull_request_id` text NOT NULL, `user_id` text NOT NULL, `assigned_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`pull_request_id`) REFERENCES `pull_requests`(`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 `pull_request_checks` ( `id` text PRIMARY KEY NOT NULL, `pull_request_id` text NOT NULL, `name` text NOT NULL, `status` text NOT NULL, `conclusion` text, `head_sha` text NOT NULL, `external_id` text, `details_url` text, `output` text, `started_at` text, `completed_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`pull_request_id`) REFERENCES `pull_requests`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `pull_request_comments` ( `id` text PRIMARY KEY NOT NULL, `pull_request_id` text NOT NULL, `review_id` text, `author_id` text NOT NULL, `body` text NOT NULL, `path` text, `line` integer, `side` text, `start_line` integer, `start_side` text, `commit_sha` text, `original_commit_sha` text, `original_line` integer, `in_reply_to_id` text, `reactions` text, `is_resolved` integer DEFAULT false, `resolved_by_id` text, `resolved_at` text, `is_edited` integer DEFAULT false, `edited_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`pull_request_id`) REFERENCES `pull_requests`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`review_id`) REFERENCES `pull_request_reviews`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`in_reply_to_id`) REFERENCES `pull_request_comments`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`resolved_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `pull_request_labels` ( `id` text PRIMARY KEY NOT NULL, `pull_request_id` text NOT NULL, `label_id` text NOT NULL, FOREIGN KEY (`pull_request_id`) REFERENCES `pull_requests`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`label_id`) REFERENCES `labels`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `pull_request_reviewers` ( `id` text PRIMARY KEY NOT NULL, `pull_request_id` text NOT NULL, `user_id` text NOT NULL, `is_required` integer DEFAULT false, `requested_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`pull_request_id`) REFERENCES `pull_requests`(`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 `pull_request_reviews` ( `id` text PRIMARY KEY NOT NULL, `pull_request_id` text NOT NULL, `reviewer_id` text NOT NULL, `state` text NOT NULL, `body` text, `commit_sha` text, `submitted_at` text, `dismissed_at` text, `dismissed_by_id` text, `dismissal_reason` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`pull_request_id`) REFERENCES `pull_requests`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`reviewer_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`dismissed_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `pull_requests` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `number` integer NOT NULL, `title` text NOT NULL, `body` text, `state` text DEFAULT 'open' NOT NULL, `author_id` text NOT NULL, `assignee_id` text, `milestone_id` text, `head_branch` text NOT NULL, `head_sha` text NOT NULL, `head_repository_id` text, `base_branch` text NOT NULL, `base_sha` text NOT NULL, `is_draft` integer DEFAULT false, `is_merged` integer DEFAULT false, `merged_at` text, `merged_by_id` text, `merge_sha` text, `merge_method` text, `additions` integer DEFAULT 0, `deletions` integer DEFAULT 0, `changed_files` integer DEFAULT 0, `comment_count` integer DEFAULT 0, `review_count` integer DEFAULT 0, `mergeable` integer, `mergeable_state` text, `rebaseable` integer, `maintainer_can_modify` integer DEFAULT true, `allow_auto_merge` integer DEFAULT false, `auto_merge_method` text, `closed_at` text, `closed_by_id` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`assignee_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`milestone_id`) REFERENCES `milestones`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`head_repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`merged_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`closed_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `scheduled_workflows` ( `id` text PRIMARY KEY NOT NULL, `workflow_id` text NOT NULL, `cron_expression` text NOT NULL, `timezone` text DEFAULT 'UTC', `is_enabled` integer DEFAULT true, `last_run_at` text, `next_run_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`workflow_id`) REFERENCES `workflows`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `workflow_artifacts` ( `id` text PRIMARY KEY NOT NULL, `run_id` text NOT NULL, `job_id` text, `name` text NOT NULL, `size_bytes` integer NOT NULL, `storage_path` text NOT NULL, `mime_type` text, `download_count` integer DEFAULT 0, `expires_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`run_id`) REFERENCES `workflow_runs`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`job_id`) REFERENCES `workflow_jobs`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `workflow_jobs` ( `id` text PRIMARY KEY NOT NULL, `run_id` text NOT NULL, `name` text NOT NULL, `status` text DEFAULT 'queued' NOT NULL, `conclusion` text, `runner_id` text, `runner_name` text, `runner_group_id` text, `runner_group_name` text, `container_id` text, `container_image` text, `needs` text, `environment` text, `environment_url` text, `matrix` text, `started_at` text, `completed_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`run_id`) REFERENCES `workflow_runs`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `workflow_logs` ( `id` text PRIMARY KEY NOT NULL, `job_id` text NOT NULL, `step_id` text, `log_level` text DEFAULT 'info' NOT NULL, `message` text NOT NULL, `timestamp` text NOT NULL, `line_number` integer, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`job_id`) REFERENCES `workflow_jobs`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`step_id`) REFERENCES `workflow_steps`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `workflow_runs` ( `id` text PRIMARY KEY NOT NULL, `workflow_id` text NOT NULL, `repository_id` text NOT NULL, `run_number` integer NOT NULL, `run_attempt` integer DEFAULT 1 NOT NULL, `name` text NOT NULL, `display_title` text, `status` text DEFAULT 'queued' NOT NULL, `conclusion` text, `event` text NOT NULL, `head_branch` text, `head_sha` text NOT NULL, `base_branch` text, `base_sha` text, `pull_request_id` text, `triggered_by_id` text, `started_at` text, `completed_at` text, `workflow_config` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`workflow_id`) REFERENCES `workflows`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`pull_request_id`) REFERENCES `pull_requests`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`triggered_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `workflow_secrets` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `name` text NOT NULL, `encrypted_value` text NOT NULL, `environment` text, `created_by_id` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`created_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `workflow_steps` ( `id` text PRIMARY KEY NOT NULL, `job_id` text NOT NULL, `number` integer NOT NULL, `name` text NOT NULL, `status` text DEFAULT 'queued' NOT NULL, `conclusion` text, `uses` text, `run` text, `shell` text, `working_directory` text, `env` text, `with` text, `if` text, `continue_on_error` integer DEFAULT false, `timeout_minutes` integer, `started_at` text, `completed_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`job_id`) REFERENCES `workflow_jobs`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `workflow_variables` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `name` text NOT NULL, `value` text NOT NULL, `environment` text, `created_by_id` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`created_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `workflows` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `name` text NOT NULL, `path` text NOT NULL, `state` text DEFAULT 'active' NOT NULL, `badge_url` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `wiki_pages` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `slug` text NOT NULL, `title` text NOT NULL, `content` text NOT NULL, `format` text DEFAULT 'markdown' NOT NULL, `parent_id` text, `order` integer DEFAULT 0, `last_editor_id` text, `view_count` integer DEFAULT 0, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`parent_id`) REFERENCES `wiki_pages`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`last_editor_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `wiki_revisions` ( `id` text PRIMARY KEY NOT NULL, `page_id` text NOT NULL, `content` text NOT NULL, `message` text, `author_id` text NOT NULL, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`page_id`) REFERENCES `wiki_pages`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `organization_members` ( `id` text PRIMARY KEY NOT NULL, `organization_id` text NOT NULL, `user_id` text NOT NULL, `role` text DEFAULT 'member' NOT NULL, `joined_at` text DEFAULT 'CURRENT_TIMESTAMP' 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, `display_name` text, `description` text, `avatar_url` text, `website` text, `location` text, `email` text, `is_verified` integer DEFAULT false, `visibility` text DEFAULT 'public' NOT NULL, `default_repo_permission` text DEFAULT 'read', `members_can_create_repos` integer DEFAULT true, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL ); --> statement-breakpoint CREATE UNIQUE INDEX `organizations_name_unique` ON `organizations` (`name`);--> statement-breakpoint CREATE TABLE `team_members` ( `id` text PRIMARY KEY NOT NULL, `team_id` text NOT NULL, `user_id` text NOT NULL, `role` text DEFAULT 'member' NOT NULL, `joined_at` text DEFAULT 'CURRENT_TIMESTAMP' 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 `team_repositories` ( `id` text PRIMARY KEY NOT NULL, `team_id` text NOT NULL, `repository_id` text NOT NULL, `permission` text DEFAULT 'read' NOT NULL, `added_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`team_id`) REFERENCES `teams`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`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, `slug` text NOT NULL, `description` text, `privacy` text DEFAULT 'visible' NOT NULL, `parent_id` text, `permission` text DEFAULT 'read' NOT NULL, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`parent_id`) REFERENCES `teams`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `activities` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `repository_id` text, `organization_id` text, `type` text NOT NULL, `action` text NOT NULL, `ref_type` text, `ref_name` text, `target_type` text, `target_id` text, `payload` text, `is_public` integer DEFAULT true, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `audit_logs` ( `id` text PRIMARY KEY NOT NULL, `user_id` text, `organization_id` text, `repository_id` text, `action` text NOT NULL, `actor_type` text DEFAULT 'user' NOT NULL, `actor_id` text, `actor_ip` text, `actor_user_agent` text, `target_type` text, `target_id` text, `target_name` text, `data` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `notifications` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `repository_id` text, `type` text NOT NULL, `title` text NOT NULL, `body` text, `url` text, `actor_id` text, `subject_type` text, `subject_id` text, `reason` text NOT NULL, `is_read` integer DEFAULT false, `read_at` text, `is_archived` integer DEFAULT false, `archived_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`actor_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `security_scans` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `status` text DEFAULT 'queued' NOT NULL, `started_at` integer, `completed_at` integer, `critical_count` integer DEFAULT 0, `high_count` integer DEFAULT 0, `medium_count` integer DEFAULT 0, `low_count` integer DEFAULT 0, `unknown_count` integer DEFAULT 0, `logs` text, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `security_vulnerabilities` ( `id` text PRIMARY KEY NOT NULL, `scan_id` text NOT NULL, `vulnerability_id` text NOT NULL, `pkg_name` text NOT NULL, `installed_version` text, `fixed_version` text, `severity` text NOT NULL, `title` text, `description` text, `target` text, `class` text, FOREIGN KEY (`scan_id`) REFERENCES `security_scans`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `pipeline_runners` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text, `token` text NOT NULL, `name` text NOT NULL, `os` text, `arch` text, `version` text, `status` text DEFAULT 'offline' NOT NULL, `last_seen_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `pr_stack_entries` ( `id` text PRIMARY KEY NOT NULL, `stack_id` text NOT NULL, `pull_request_id` text NOT NULL, `stack_order` integer NOT NULL, `parent_pr_id` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`stack_id`) REFERENCES `pr_stacks`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`pull_request_id`) REFERENCES `pull_requests`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`parent_pr_id`) REFERENCES `pull_requests`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `pr_stacks` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `name` text, `base_branch` text NOT NULL, `status` text DEFAULT 'active' NOT NULL, `created_by_id` text NOT NULL, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`created_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `merge_queue` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `pull_request_id` text NOT NULL, `stack_id` text, `status` text DEFAULT 'pending' NOT NULL, `priority` integer DEFAULT 0 NOT NULL, `position` integer, `ci_status` text DEFAULT 'pending', `ci_run_id` text, `added_by_id` text NOT NULL, `added_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `estimated_merge_at` text, `started_at` text, `completed_at` text, `failure_reason` text, `retry_count` integer DEFAULT 0, `merge_method` text DEFAULT 'merge', `delete_on_merge` integer DEFAULT true, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`pull_request_id`) REFERENCES `pull_requests`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`stack_id`) REFERENCES `pr_stacks`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`added_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `ai_review_suggestions` ( `id` text PRIMARY KEY NOT NULL, `ai_review_id` text NOT NULL, `path` text NOT NULL, `line` integer, `end_line` integer, `severity` text NOT NULL, `type` text NOT NULL, `category` text, `title` text NOT NULL, `message` text NOT NULL, `suggested_fix` text, `explanation` text, `is_applied` integer DEFAULT false, `is_dismissed` integer DEFAULT false, `applied_at` text, `applied_by_id` text, `dismissed_at` text, `dismissed_by_id` text, `dismiss_reason` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`ai_review_id`) REFERENCES `ai_reviews`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`applied_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action, FOREIGN KEY (`dismissed_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `ai_reviews` ( `id` text PRIMARY KEY NOT NULL, `pull_request_id` text NOT NULL, `status` text DEFAULT 'pending' NOT NULL, `model` text NOT NULL, `provider` text NOT NULL, `stack_context` text, `includes_stack_context` integer DEFAULT false, `summary` text, `overall_severity` text, `suggestions_count` integer DEFAULT 0, `tokens_used` integer, `prompt_tokens` integer, `completion_tokens` integer, `cost_cents` integer, `raw_response` text, `triggered_by_id` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `started_at` text, `completed_at` text, `error_message` text, FOREIGN KEY (`pull_request_id`) REFERENCES `pull_requests`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`triggered_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `pr_metrics` ( `id` text PRIMARY KEY NOT NULL, `pull_request_id` text NOT NULL, `repository_id` text NOT NULL, `author_id` text NOT NULL, `time_to_first_review` integer, `time_to_approval` integer, `time_to_merge` integer, `total_cycle_time` integer, `review_rounds` integer DEFAULT 1, `reviewers_count` integer DEFAULT 0, `comments_count` integer DEFAULT 0, `changes_requested_count` integer DEFAULT 0, `lines_added` integer DEFAULT 0, `lines_removed` integer DEFAULT 0, `files_changed` integer DEFAULT 0, `commits` integer DEFAULT 1, `is_stacked` integer DEFAULT false, `stack_position` integer, `pr_created_at` text, `first_review_at` text, `approved_at` text, `merged_at` text, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`pull_request_id`) REFERENCES `pull_requests`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`author_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `repo_metrics` ( `id` text PRIMARY KEY NOT NULL, `repository_id` text NOT NULL, `week_of` text NOT NULL, `prs_opened` integer DEFAULT 0, `prs_merged` integer DEFAULT 0, `prs_closed` integer DEFAULT 0, `avg_time_to_first_review` integer, `avg_time_to_merge` integer, `avg_review_rounds` integer, `avg_lines_changed` integer, `avg_files_changed` integer, `stacked_prs` integer DEFAULT 0, `stacked_prs_percentage` integer DEFAULT 0, `active_authors` integer DEFAULT 0, `active_reviewers` integer DEFAULT 0, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `review_metrics` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `repository_id` text, `organization_id` text, `week_of` text NOT NULL, `prs_authored` integer DEFAULT 0, `prs_authored_merged` integer DEFAULT 0, `avg_time_to_merge_authored` integer, `lines_authored_added` integer DEFAULT 0, `lines_authored_removed` integer DEFAULT 0, `prs_reviewed` integer DEFAULT 0, `avg_time_to_review` integer, `comments_given` integer DEFAULT 0, `approvals_given` integer DEFAULT 0, `changes_requested_given` integer DEFAULT 0, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE no action ); --> statement-breakpoint CREATE TABLE `slack_channel_mappings` ( `id` text PRIMARY KEY NOT NULL, `workspace_id` text NOT NULL, `repository_id` text NOT NULL, `channel_id` text NOT NULL, `channel_name` text, `notify_on` text DEFAULT '["pr_created","pr_merged","review_requested","ci_failed"]', `notify_branches` text, `notify_authors` text, `is_active` integer DEFAULT true, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `updated_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`workspace_id`) REFERENCES `slack_workspaces`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`repository_id`) REFERENCES `repositories`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `slack_user_mappings` ( `id` text PRIMARY KEY NOT NULL, `user_id` text NOT NULL, `workspace_id` text NOT NULL, `slack_user_id` text NOT NULL, `slack_username` text, `dm_preferences` text DEFAULT '{"review_requested":true,"pr_approved":true,"ci_failed":true}', `dnd_enabled` integer DEFAULT false, `dnd_start` text, `dnd_end` text, `dnd_timezone` text, `is_active` integer DEFAULT true, `created_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`workspace_id`) REFERENCES `slack_workspaces`(`id`) ON UPDATE no action ON DELETE cascade ); --> statement-breakpoint CREATE TABLE `slack_workspaces` ( `id` text PRIMARY KEY NOT NULL, `organization_id` text, `team_id` text NOT NULL, `team_name` text, `team_domain` text, `access_token` text NOT NULL, `bot_user_id` text, `bot_access_token` text, `scopes` text, `installed_by_id` text NOT NULL, `installed_at` text DEFAULT 'CURRENT_TIMESTAMP' NOT NULL, `is_active` integer DEFAULT true, `last_used_at` text, FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`) ON UPDATE no action ON DELETE cascade, FOREIGN KEY (`installed_by_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action );