diff --git a/src/db/migrations/0003_goofy_the_leader.sql b/src/db/migrations/0003_goofy_the_leader.sql new file mode 100644 index 000000000..7a3a8a7d9 --- /dev/null +++ b/src/db/migrations/0003_goofy_the_leader.sql @@ -0,0 +1,78 @@ +CREATE TABLE `project_members` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `project_id` integer NOT NULL, + `user_id` integer NOT NULL, + `role` text DEFAULT 'editor' NOT NULL, + `added_at` integer 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 INDEX `project_members_project_user_unique` ON `project_members` (`project_id`,`user_id`);--> statement-breakpoint +CREATE INDEX `idx_project_members_user` ON `project_members` (`user_id`);--> statement-breakpoint +CREATE TABLE `team_members` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `team_id` text NOT NULL, + `user_id` integer NOT NULL, + `role` text DEFAULT 'editor' NOT NULL, + `joined_at` integer 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 INDEX `team_members_team_user_unique` ON `team_members` (`team_id`,`user_id`);--> statement-breakpoint +CREATE INDEX `idx_team_members_user` ON `team_members` (`user_id`);--> statement-breakpoint +CREATE TABLE `teams` ( + `id` text PRIMARY KEY NOT NULL, + `name` text NOT NULL, + `owner_id` integer NOT NULL, + `created_at` integer NOT NULL, + `updated_at` integer NOT NULL, + FOREIGN KEY (`owner_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action +); +--> statement-breakpoint +CREATE INDEX `idx_teams_owner` ON `teams` (`owner_id`);--> statement-breakpoint +DROP INDEX "character_relationships_unique_pair";--> statement-breakpoint +DROP INDEX "project_members_project_user_unique";--> statement-breakpoint +DROP INDEX "idx_project_members_user";--> statement-breakpoint +DROP INDEX "revision_changes_revision_idx";--> statement-breakpoint +DROP INDEX "revision_changes_type_idx";--> statement-breakpoint +DROP INDEX "revisions_script_version_idx";--> statement-breakpoint +DROP INDEX "revisions_script_branch_idx";--> statement-breakpoint +DROP INDEX "revisions_author_idx";--> statement-breakpoint +DROP INDEX "team_members_team_user_unique";--> statement-breakpoint +DROP INDEX "idx_team_members_user";--> statement-breakpoint +DROP INDEX "idx_teams_owner";--> statement-breakpoint +DROP INDEX "users_email_unique";--> statement-breakpoint +DROP INDEX "users_username_unique";--> statement-breakpoint +DROP INDEX "waitlist_signups_email_unique";--> statement-breakpoint +ALTER TABLE `alert_rules` ALTER COLUMN "created_at" TO "created_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.161Z"';--> statement-breakpoint +CREATE UNIQUE INDEX `character_relationships_unique_pair` ON `character_relationships` (`character_a_id`,`character_b_id`);--> statement-breakpoint +CREATE INDEX `revision_changes_revision_idx` ON `revision_changes` (`revision_id`);--> statement-breakpoint +CREATE INDEX `revision_changes_type_idx` ON `revision_changes` (`change_type`);--> statement-breakpoint +CREATE INDEX `revisions_script_version_idx` ON `revisions` (`script_id`,`version_number`);--> statement-breakpoint +CREATE INDEX `revisions_script_branch_idx` ON `revisions` (`script_id`,`branch_name`);--> statement-breakpoint +CREATE INDEX `revisions_author_idx` ON `revisions` (`author_id`);--> statement-breakpoint +CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);--> statement-breakpoint +CREATE UNIQUE INDEX `users_username_unique` ON `users` (`username`);--> statement-breakpoint +CREATE UNIQUE INDEX `waitlist_signups_email_unique` ON `waitlist_signups` (`email`);--> statement-breakpoint +ALTER TABLE `alert_rules` ALTER COLUMN "updated_at" TO "updated_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.161Z"';--> statement-breakpoint +ALTER TABLE `alerts` ALTER COLUMN "created_at" TO "created_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.165Z"';--> statement-breakpoint +ALTER TABLE `alerts` ALTER COLUMN "acknowledged_by" TO "acknowledged_by" integer REFERENCES users(id) ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE `cohort_members` ALTER COLUMN "joined_at" TO "joined_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.174Z"';--> statement-breakpoint +ALTER TABLE `cohort_members` ALTER COLUMN "user_id" TO "user_id" integer NOT NULL REFERENCES users(id) ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE `cohorts` ALTER COLUMN "created_at" TO "created_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.174Z"';--> statement-breakpoint +ALTER TABLE `cohorts` ALTER COLUMN "updated_at" TO "updated_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.174Z"';--> statement-breakpoint +ALTER TABLE `kpi_snapshots` ALTER COLUMN "created_at" TO "created_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.158Z"';--> statement-breakpoint +ALTER TABLE `nps_responses` ALTER COLUMN "created_at" TO "created_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.171Z"';--> statement-breakpoint +ALTER TABLE `projects` ALTER COLUMN "created_at" TO "created_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.134Z"';--> statement-breakpoint +ALTER TABLE `projects` ALTER COLUMN "updated_at" TO "updated_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.134Z"';--> statement-breakpoint +ALTER TABLE `scheduled_reports` ALTER COLUMN "created_at" TO "created_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.168Z"';--> statement-breakpoint +ALTER TABLE `scheduled_reports` ALTER COLUMN "updated_at" TO "updated_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.168Z"';--> statement-breakpoint +ALTER TABLE `scripts` ALTER COLUMN "created_at" TO "created_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.141Z"';--> statement-breakpoint +ALTER TABLE `scripts` ALTER COLUMN "updated_at" TO "updated_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.141Z"';--> statement-breakpoint +ALTER TABLE `users` ALTER COLUMN "created_at" TO "created_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.126Z"';--> statement-breakpoint +ALTER TABLE `users` ALTER COLUMN "updated_at" TO "updated_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.126Z"';--> statement-breakpoint +ALTER TABLE `waitlist_events` ALTER COLUMN "created_at" TO "created_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.178Z"';--> statement-breakpoint +ALTER TABLE `waitlist_signups` ALTER COLUMN "created_at" TO "created_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.178Z"';--> statement-breakpoint +ALTER TABLE `waitlist_signups` ALTER COLUMN "updated_at" TO "updated_at" integer NOT NULL DEFAULT '"2026-04-26T22:14:11.178Z"'; \ No newline at end of file diff --git a/src/db/migrations/meta/0003_snapshot.json b/src/db/migrations/meta/0003_snapshot.json new file mode 100644 index 000000000..261dc6de4 --- /dev/null +++ b/src/db/migrations/meta/0003_snapshot.json @@ -0,0 +1,1984 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "75b91b1f-8b87-44fc-afa4-9c7d3940cbdd", + "prevId": "ff848173-6ac9-4890-b3f1-729d99eb07cd", + "tables": { + "alert_rules": { + "name": "alert_rules", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kpi_key": { + "name": "kpi_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "condition": { + "name": "condition", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "threshold": { + "name": "threshold", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'medium'" + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "cooldown_minutes": { + "name": "cooldown_minutes", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 60 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.161Z\"'" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.161Z\"'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "alerts": { + "name": "alerts", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "rule_id": { + "name": "rule_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kpi_key": { + "name": "kpi_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kpi_value": { + "name": "kpi_value", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "threshold": { + "name": "threshold", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "severity": { + "name": "severity", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "was_sent": { + "name": "was_sent", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "sent_at": { + "name": "sent_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "acknowledged_by": { + "name": "acknowledged_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "acknowledged_at": { + "name": "acknowledged_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.165Z\"'" + } + }, + "indexes": {}, + "foreignKeys": { + "alerts_rule_id_alert_rules_id_fk": { + "name": "alerts_rule_id_alert_rules_id_fk", + "tableFrom": "alerts", + "tableTo": "alert_rules", + "columnsFrom": [ + "rule_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "alerts_acknowledged_by_users_id_fk": { + "name": "alerts_acknowledged_by_users_id_fk", + "tableFrom": "alerts", + "tableTo": "users", + "columnsFrom": [ + "acknowledged_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "character_relationships": { + "name": "character_relationships", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "character_a_id": { + "name": "character_a_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "character_b_id": { + "name": "character_b_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "relationship_type": { + "name": "relationship_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "strength": { + "name": "strength", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 50 + }, + "is_antagonistic": { + "name": "is_antagonistic", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "character_relationships_unique_pair": { + "name": "character_relationships_unique_pair", + "columns": [ + "character_a_id", + "character_b_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "character_relationships_character_a_id_characters_id_fk": { + "name": "character_relationships_character_a_id_characters_id_fk", + "tableFrom": "character_relationships", + "tableTo": "characters", + "columnsFrom": [ + "character_a_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "character_relationships_character_b_id_characters_id_fk": { + "name": "character_relationships_character_b_id_characters_id_fk", + "tableFrom": "character_relationships", + "tableTo": "characters", + "columnsFrom": [ + "character_b_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "characters": { + "name": "characters", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'supporting'" + }, + "bio": { + "name": "bio", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "arc": { + "name": "arc", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "arc_type": { + "name": "arc_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "age": { + "name": "age", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "gender": { + "name": "gender", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "voice": { + "name": "voice", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "traits": { + "name": "traits", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "motivation": { + "name": "motivation", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "conflict": { + "name": "conflict", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "secret": { + "name": "secret", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_url": { + "name": "image_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "characters_project_id_projects_id_fk": { + "name": "characters_project_id_projects_id_fk", + "tableFrom": "characters", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "cohort_members": { + "name": "cohort_members", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "cohort_id": { + "name": "cohort_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "joined_at": { + "name": "joined_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.174Z\"'" + } + }, + "indexes": {}, + "foreignKeys": { + "cohort_members_cohort_id_cohorts_id_fk": { + "name": "cohort_members_cohort_id_cohorts_id_fk", + "tableFrom": "cohort_members", + "tableTo": "cohorts", + "columnsFrom": [ + "cohort_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "cohort_members_user_id_users_id_fk": { + "name": "cohort_members_user_id_users_id_fk", + "tableFrom": "cohort_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "cohorts": { + "name": "cohorts", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "definition": { + "name": "definition", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "period_start": { + "name": "period_start", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "period_end": { + "name": "period_end", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "retention_data": { + "name": "retention_data", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.174Z\"'" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.174Z\"'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "kpi_snapshots": { + "name": "kpi_snapshots", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "kpi_key": { + "name": "kpi_key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kpi_value": { + "name": "kpi_value", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "period_start": { + "name": "period_start", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "period_end": { + "name": "period_end", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.158Z\"'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "nps_responses": { + "name": "nps_responses", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "score": { + "name": "score", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category": { + "name": "category", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feedback": { + "name": "feedback", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "survey_id": { + "name": "survey_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "respondent_email": { + "name": "respondent_email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.171Z\"'" + } + }, + "indexes": {}, + "foreignKeys": { + "nps_responses_user_id_users_id_fk": { + "name": "nps_responses_user_id_users_id_fk", + "tableFrom": "nps_responses", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "project_members": { + "name": "project_members", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'editor'" + }, + "added_at": { + "name": "added_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "project_members_project_user_unique": { + "name": "project_members_project_user_unique", + "columns": [ + "project_id", + "user_id" + ], + "isUnique": false + }, + "idx_project_members_user": { + "name": "idx_project_members_user", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "project_members_project_id_projects_id_fk": { + "name": "project_members_project_id_projects_id_fk", + "tableFrom": "project_members", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "project_members_user_id_users_id_fk": { + "name": "project_members_user_id_users_id_fk", + "tableFrom": "project_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "projects": { + "name": "projects", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "owner_id": { + "name": "owner_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "is_public": { + "name": "is_public", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.134Z\"'" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.134Z\"'" + } + }, + "indexes": {}, + "foreignKeys": { + "projects_owner_id_users_id_fk": { + "name": "projects_owner_id_users_id_fk", + "tableFrom": "projects", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "revision_changes": { + "name": "revision_changes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "revision_id": { + "name": "revision_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "change_type": { + "name": "change_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "element_type": { + "name": "element_type", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "old_content": { + "name": "old_content", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "new_content": { + "name": "new_content", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "scene_number": { + "name": "scene_number", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "line_number": { + "name": "line_number", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "page_number": { + "name": "page_number", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "revision_changes_revision_idx": { + "name": "revision_changes_revision_idx", + "columns": [ + "revision_id" + ], + "isUnique": false + }, + "revision_changes_type_idx": { + "name": "revision_changes_type_idx", + "columns": [ + "change_type" + ], + "isUnique": false + } + }, + "foreignKeys": { + "revision_changes_revision_id_revisions_id_fk": { + "name": "revision_changes_revision_id_revisions_id_fk", + "tableFrom": "revision_changes", + "tableTo": "revisions", + "columnsFrom": [ + "revision_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "revisions": { + "name": "revisions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "script_id": { + "name": "script_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "version_number": { + "name": "version_number", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "branch_name": { + "name": "branch_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'main'" + }, + "parent_revision_id": { + "name": "parent_revision_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "summary": { + "name": "summary", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "author_id": { + "name": "author_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'draft'" + }, + "reviewed_by_id": { + "name": "reviewed_by_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "revisions_script_version_idx": { + "name": "revisions_script_version_idx", + "columns": [ + "script_id", + "version_number" + ], + "isUnique": false + }, + "revisions_script_branch_idx": { + "name": "revisions_script_branch_idx", + "columns": [ + "script_id", + "branch_name" + ], + "isUnique": false + }, + "revisions_author_idx": { + "name": "revisions_author_idx", + "columns": [ + "author_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "revisions_script_id_scripts_id_fk": { + "name": "revisions_script_id_scripts_id_fk", + "tableFrom": "revisions", + "tableTo": "scripts", + "columnsFrom": [ + "script_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "revisions_author_id_users_id_fk": { + "name": "revisions_author_id_users_id_fk", + "tableFrom": "revisions", + "tableTo": "users", + "columnsFrom": [ + "author_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "revisions_reviewed_by_id_users_id_fk": { + "name": "revisions_reviewed_by_id_users_id_fk", + "tableFrom": "revisions", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "scene_characters": { + "name": "scene_characters", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "scene_id": { + "name": "scene_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "character_id": { + "name": "character_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "screen_time": { + "name": "screen_time", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "dialogue_lines": { + "name": "dialogue_lines", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false, + "default": 0 + } + }, + "indexes": {}, + "foreignKeys": { + "scene_characters_scene_id_scenes_id_fk": { + "name": "scene_characters_scene_id_scenes_id_fk", + "tableFrom": "scene_characters", + "tableTo": "scenes", + "columnsFrom": [ + "scene_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "scene_characters_character_id_characters_id_fk": { + "name": "scene_characters_character_id_characters_id_fk", + "tableFrom": "scene_characters", + "tableTo": "characters", + "columnsFrom": [ + "character_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "scenes": { + "name": "scenes", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "order": { + "name": "order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "scenes_project_id_projects_id_fk": { + "name": "scenes_project_id_projects_id_fk", + "tableFrom": "scenes", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "scheduled_reports": { + "name": "scheduled_reports", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "report_type": { + "name": "report_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "schedule": { + "name": "schedule", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "recipients": { + "name": "recipients", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "format": { + "name": "format", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'slack'" + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "last_run_at": { + "name": "last_run_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "next_run_at": { + "name": "next_run_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.168Z\"'" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.168Z\"'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "scripts": { + "name": "scripts", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "project_id": { + "name": "project_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "genre": { + "name": "genre", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "logline": { + "name": "logline", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'draft'" + }, + "current_version": { + "name": "current_version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.141Z\"'" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.141Z\"'" + } + }, + "indexes": {}, + "foreignKeys": { + "scripts_project_id_projects_id_fk": { + "name": "scripts_project_id_projects_id_fk", + "tableFrom": "scripts", + "tableTo": "projects", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "team_members": { + "name": "team_members", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "team_id": { + "name": "team_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'editor'" + }, + "joined_at": { + "name": "joined_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "team_members_team_user_unique": { + "name": "team_members_team_user_unique", + "columns": [ + "team_id", + "user_id" + ], + "isUnique": false + }, + "idx_team_members_user": { + "name": "idx_team_members_user", + "columns": [ + "user_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "team_members_team_id_teams_id_fk": { + "name": "team_members_team_id_teams_id_fk", + "tableFrom": "team_members", + "tableTo": "teams", + "columnsFrom": [ + "team_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "team_members_user_id_users_id_fk": { + "name": "team_members_user_id_users_id_fk", + "tableFrom": "team_members", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "teams": { + "name": "teams", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "owner_id": { + "name": "owner_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_teams_owner": { + "name": "idx_teams_owner", + "columns": [ + "owner_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "teams_owner_id_users_id_fk": { + "name": "teams_owner_id_users_id_fk", + "tableFrom": "teams", + "tableTo": "users", + "columnsFrom": [ + "owner_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "full_name": { + "name": "full_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "avatar_url": { + "name": "avatar_url", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'viewer'" + }, + "is_active": { + "name": "is_active", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "last_login_at": { + "name": "last_login_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.126Z\"'" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.126Z\"'" + } + }, + "indexes": { + "users_email_unique": { + "name": "users_email_unique", + "columns": [ + "email" + ], + "isUnique": true + }, + "users_username_unique": { + "name": "users_username_unique", + "columns": [ + "username" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "waitlist_events": { + "name": "waitlist_events", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "signup_id": { + "name": "signup_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "event_type": { + "name": "event_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "event_data": { + "name": "event_data", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.178Z\"'" + } + }, + "indexes": {}, + "foreignKeys": { + "waitlist_events_signup_id_waitlist_signups_id_fk": { + "name": "waitlist_events_signup_id_waitlist_signups_id_fk", + "tableFrom": "waitlist_events", + "tableTo": "waitlist_signups", + "columnsFrom": [ + "signup_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "waitlist_signups": { + "name": "waitlist_signups", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'organic'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'waitlist'" + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.178Z\"'" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'\"2026-04-26T22:14:11.178Z\"'" + } + }, + "indexes": { + "waitlist_signups_email_unique": { + "name": "waitlist_signups_email_unique", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/src/db/migrations/meta/_journal.json b/src/db/migrations/meta/_journal.json index c8d9391ea..199144426 100644 --- a/src/db/migrations/meta/_journal.json +++ b/src/db/migrations/meta/_journal.json @@ -22,6 +22,13 @@ "when": 1777198863362, "tag": "0002_chemical_shocker", "breakpoints": true + }, + { + "idx": 3, + "version": "6", + "when": 1777241651204, + "tag": "0003_goofy_the_leader", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/db/schema/alerts.ts b/src/db/schema/alerts.ts index 8887473f7..e936104f9 100644 --- a/src/db/schema/alerts.ts +++ b/src/db/schema/alerts.ts @@ -1,5 +1,6 @@ import { sqliteTable, text, integer, real } from "drizzle-orm/sqlite-core"; import { alertRules } from "./alert_rules"; +import { users } from "./users"; export const alerts = sqliteTable("alerts", { id: integer("id").primaryKey({ autoIncrement: true }), @@ -11,7 +12,7 @@ export const alerts = sqliteTable("alerts", { message: text("message").notNull(), wasSent: integer("was_sent", { mode: "boolean" }).notNull().default(false), sentAt: integer("sent_at", { mode: "timestamp" }), - acknowledgedBy: integer("acknowledged_by"), + acknowledgedBy: integer("acknowledged_by").references(() => users.id), acknowledgedAt: integer("acknowledged_at", { mode: "timestamp" }), createdAt: integer("created_at", { mode: "timestamp" }).notNull().default(new Date()), }); diff --git a/src/db/schema/cohorts.ts b/src/db/schema/cohorts.ts index 17dbd3803..7ac8ecec9 100644 --- a/src/db/schema/cohorts.ts +++ b/src/db/schema/cohorts.ts @@ -1,4 +1,5 @@ import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core"; +import { users } from "./users"; export const cohorts = sqliteTable("cohorts", { id: integer("id").primaryKey({ autoIncrement: true }), @@ -16,7 +17,7 @@ export const cohorts = sqliteTable("cohorts", { export const cohortMembers = sqliteTable("cohort_members", { id: integer("id").primaryKey({ autoIncrement: true }), cohortId: integer("cohort_id").notNull().references(() => cohorts.id), - userId: integer("user_id").notNull(), + userId: integer("user_id").notNull().references(() => users.id), joinedAt: integer("joined_at", { mode: "timestamp" }).notNull().default(new Date()), }); diff --git a/src/db/schema/index.ts b/src/db/schema/index.ts index b4cc9139b..114f3066d 100644 --- a/src/db/schema/index.ts +++ b/src/db/schema/index.ts @@ -1,5 +1,7 @@ export { users, type User, type NewUser } from "./users"; +export { teams, teamMembers, type Team, type NewTeam, type TeamMember, type NewTeamMember } from "./teams"; export { projects, type Project, type NewProject } from "./projects"; +export { projectMembers, type ProjectMember, type NewProjectMember } from "./project_members"; export { scripts, type Script, type NewScript } from "./scripts"; export { characters, characterRelationships, type Character, type NewCharacter, type CharacterRelationship, type NewCharacterRelationship } from "./characters"; export { scenes, sceneCharacters, type Scene, type NewScene, type SceneCharacter, type NewSceneCharacter } from "./scenes"; diff --git a/src/db/seed.ts b/src/db/seed.ts index 6f59a3f83..e4fbee5af 100644 --- a/src/db/seed.ts +++ b/src/db/seed.ts @@ -43,8 +43,9 @@ export async function seedDatabase() { // Create test character const character = await db.insert(characters).values({ - scriptId: script[0].id, + projectId: project[0].id, name: "John Doe", + slug: "john-doe", role: "protagonist", description: "The main character", age: 30, @@ -55,14 +56,10 @@ export async function seedDatabase() { // Create test scene const scene = await db.insert(scenes).values({ - scriptId: script[0].id, - sceneNumber: 1, - actNumber: 1, - slugline: "INT. OFFICE - DAY", - location: "Office", - timeOfDay: "DAY", + projectId: project[0].id, + title: "INT. OFFICE - DAY", content: "John sits at his desk, contemplating his next move.", - summary: "John in his office", + order: 1, }).returning(); if (!scene[0]) throw new Error("Failed to create scene");