all repos — stealth-developers @ 1af6d44502a1ec892925954c311fb0a2560f9bba

db: add ticket schemas
vi did:web:vt3e.cat
Wed, 27 May 2026 00:30:22 +0100
commit

1af6d44502a1ec892925954c311fb0a2560f9bba

parent

215ea15b4961e12482df6962bea07f7ee5cb98af

A pkgs/db/drizzle/20260526232651_woozy_shinko_yamashiro/migration.sql

@@ -0,0 +1,63 @@

+CREATE TABLE `tickets` ( + `id` integer PRIMARY KEY AUTOINCREMENT, + `anonymous_id` text NOT NULL, + `status` text NOT NULL, + `channel_id` text NOT NULL, + `close_reason` text, + `private_notes` text, + `opened_at` integer NOT NULL, + `closed_at` integer, + `opened_by` integer NOT NULL, + `open_reason` text, + `subject` integer NOT NULL, + `claimed_by` integer, + `claimed_at` integer, + `thanked_at` integer, + `warned_at` integer, + `last_message_at` integer, + `has_moderator_message` integer, + `has_author_message` integer, + CONSTRAINT `fk_tickets_opened_by_actors_id_fk` FOREIGN KEY (`opened_by`) REFERENCES `actors`(`id`), + CONSTRAINT `fk_tickets_subject_actors_id_fk` FOREIGN KEY (`subject`) REFERENCES `actors`(`id`), + CONSTRAINT `fk_tickets_claimed_by_actors_id_fk` FOREIGN KEY (`claimed_by`) REFERENCES `actors`(`id`) +); +--> statement-breakpoint +CREATE TABLE `ticket_attachments` ( + `id` integer PRIMARY KEY AUTOINCREMENT, + `public_id` text NOT NULL, + `message_id` integer, + `ticket_id` integer NOT NULL, + `actor_id` integer NOT NULL, + `file_name` text NOT NULL, + `file_type` text NOT NULL, + `file_size` integer NOT NULL, + CONSTRAINT `fk_ticket_attachments_message_id_ticket_messages_id_fk` FOREIGN KEY (`message_id`) REFERENCES `ticket_messages`(`id`) ON DELETE CASCADE, + CONSTRAINT `fk_ticket_attachments_ticket_id_tickets_id_fk` FOREIGN KEY (`ticket_id`) REFERENCES `tickets`(`id`) ON DELETE CASCADE, + CONSTRAINT `fk_ticket_attachments_actor_id_actors_id_fk` FOREIGN KEY (`actor_id`) REFERENCES `actors`(`id`) ON DELETE CASCADE +); +--> statement-breakpoint +CREATE TABLE `ticket_messages` ( + `id` integer PRIMARY KEY AUTOINCREMENT, + `public_id` text NOT NULL, + `message_id` text, + `ticket_id` integer NOT NULL, + `actor_id` integer NOT NULL, + `content` text NOT NULL, + `actor_role` text NOT NULL, + `created_at` integer NOT NULL, + `edited_at` integer, + `deleted_at` integer, + CONSTRAINT `fk_ticket_messages_ticket_id_tickets_id_fk` FOREIGN KEY (`ticket_id`) REFERENCES `tickets`(`id`) ON DELETE CASCADE, + CONSTRAINT `fk_ticket_messages_actor_id_actors_id_fk` FOREIGN KEY (`actor_id`) REFERENCES `actors`(`id`) ON DELETE CASCADE +); +--> statement-breakpoint +CREATE TABLE `ticket_participants` ( + `id` integer PRIMARY KEY AUTOINCREMENT, + `ticket_id` integer NOT NULL, + `actor_id` integer NOT NULL, + `role` text NOT NULL, + `reason` text, + `created_at` integer NOT NULL, + CONSTRAINT `fk_ticket_participants_ticket_id_tickets_id_fk` FOREIGN KEY (`ticket_id`) REFERENCES `tickets`(`id`) ON DELETE CASCADE, + CONSTRAINT `fk_ticket_participants_actor_id_actors_id_fk` FOREIGN KEY (`actor_id`) REFERENCES `actors`(`id`) ON DELETE CASCADE +);
A pkgs/db/drizzle/20260526232651_woozy_shinko_yamashiro/snapshot.json

@@ -0,0 +1,853 @@

+{ + "version": "7", + "dialect": "sqlite", + "id": "627c7c0b-ac0a-4373-aee3-02e637e05ee6", + "prevIds": [ + "aefd1f03-d714-480c-9628-6877616b4425" + ], + "ddl": [ + { + "name": "actors", + "entityType": "tables" + }, + { + "name": "sessions", + "entityType": "tables" + }, + { + "name": "tickets", + "entityType": "tables" + }, + { + "name": "ticket_attachments", + "entityType": "tables" + }, + { + "name": "ticket_messages", + "entityType": "tables" + }, + { + "name": "ticket_participants", + "entityType": "tables" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": true, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "actors" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "discord_id", + "entityType": "columns", + "table": "actors" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "display_name", + "entityType": "columns", + "table": "actors" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "username", + "entityType": "columns", + "table": "actors" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "avatar", + "entityType": "columns", + "table": "actors" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "moderator", + "entityType": "columns", + "table": "actors" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "created_at", + "entityType": "columns", + "table": "actors" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "updated_at", + "entityType": "columns", + "table": "actors" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "deleted_at", + "entityType": "columns", + "table": "actors" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "user_id", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "access_token", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "refresh_token", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "scope", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "token_type", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "expires_at", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "created_at", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": true, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "anonymous_id", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "status", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "channel_id", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "close_reason", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "private_notes", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "opened_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "closed_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "opened_by", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "open_reason", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "subject", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "claimed_by", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "claimed_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "thanked_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "warned_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "last_message_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "has_moderator_message", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "has_author_message", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": true, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "public_id", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "message_id", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "ticket_id", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "actor_id", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "file_name", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "file_type", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "file_size", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": true, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "public_id", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "message_id", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "ticket_id", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "actor_id", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "content", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "actor_role", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "created_at", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "edited_at", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "deleted_at", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": true, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "ticket_id", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "actor_id", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "role", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "reason", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "created_at", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "columns": [ + "user_id" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "NO ACTION", + "nameExplicit": false, + "name": "fk_sessions_user_id_actors_id_fk", + "entityType": "fks", + "table": "sessions" + }, + { + "columns": [ + "opened_by" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "NO ACTION", + "nameExplicit": false, + "name": "fk_tickets_opened_by_actors_id_fk", + "entityType": "fks", + "table": "tickets" + }, + { + "columns": [ + "subject" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "NO ACTION", + "nameExplicit": false, + "name": "fk_tickets_subject_actors_id_fk", + "entityType": "fks", + "table": "tickets" + }, + { + "columns": [ + "claimed_by" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "NO ACTION", + "nameExplicit": false, + "name": "fk_tickets_claimed_by_actors_id_fk", + "entityType": "fks", + "table": "tickets" + }, + { + "columns": [ + "message_id" + ], + "tableTo": "ticket_messages", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_attachments_message_id_ticket_messages_id_fk", + "entityType": "fks", + "table": "ticket_attachments" + }, + { + "columns": [ + "ticket_id" + ], + "tableTo": "tickets", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_attachments_ticket_id_tickets_id_fk", + "entityType": "fks", + "table": "ticket_attachments" + }, + { + "columns": [ + "actor_id" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_attachments_actor_id_actors_id_fk", + "entityType": "fks", + "table": "ticket_attachments" + }, + { + "columns": [ + "ticket_id" + ], + "tableTo": "tickets", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_messages_ticket_id_tickets_id_fk", + "entityType": "fks", + "table": "ticket_messages" + }, + { + "columns": [ + "actor_id" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_messages_actor_id_actors_id_fk", + "entityType": "fks", + "table": "ticket_messages" + }, + { + "columns": [ + "ticket_id" + ], + "tableTo": "tickets", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_participants_ticket_id_tickets_id_fk", + "entityType": "fks", + "table": "ticket_participants" + }, + { + "columns": [ + "actor_id" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_participants_actor_id_actors_id_fk", + "entityType": "fks", + "table": "ticket_participants" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "actors_pk", + "table": "actors", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "sessions_pk", + "table": "sessions", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "tickets_pk", + "table": "tickets", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "ticket_attachments_pk", + "table": "ticket_attachments", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "ticket_messages_pk", + "table": "ticket_messages", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "ticket_participants_pk", + "table": "ticket_participants", + "entityType": "pks" + }, + { + "columns": [ + "discord_id" + ], + "nameExplicit": false, + "name": "actors_discord_id_unique", + "entityType": "uniques", + "table": "actors" + } + ], + "renames": [] +}
A pkgs/db/drizzle/20260526233004_opposite_captain_midlands/migration.sql

@@ -0,0 +1,9 @@

+CREATE INDEX `ticket_attachments_ticket_idx` ON `ticket_attachments` (`ticket_id`);--> statement-breakpoint +CREATE INDEX `ticket_attachments_actor_idx` ON `ticket_attachments` (`actor_id`);--> statement-breakpoint +CREATE INDEX `ticket_attachments_public_id_idx` ON `ticket_attachments` (`public_id`);--> statement-breakpoint +CREATE INDEX `ticket_messages_ticket_idx` ON `ticket_messages` (`ticket_id`);--> statement-breakpoint +CREATE INDEX `ticket_messages_actor_idx` ON `ticket_messages` (`actor_id`);--> statement-breakpoint +CREATE INDEX `ticket_messages_public_id_idx` ON `ticket_messages` (`public_id`);--> statement-breakpoint +CREATE INDEX `ticket_participants_ticket_idx` ON `ticket_participants` (`ticket_id`);--> statement-breakpoint +CREATE INDEX `ticket_participants_actor_idx` ON `ticket_participants` (`actor_id`);--> statement-breakpoint +CREATE INDEX `ticket_participants_role_idx` ON `ticket_participants` (`role`);
A pkgs/db/drizzle/20260526233004_opposite_captain_midlands/snapshot.json

@@ -0,0 +1,979 @@

+{ + "version": "7", + "dialect": "sqlite", + "id": "f1bd9a2e-f82a-4938-9bf2-2bf4ef3c7c61", + "prevIds": [ + "627c7c0b-ac0a-4373-aee3-02e637e05ee6" + ], + "ddl": [ + { + "name": "actors", + "entityType": "tables" + }, + { + "name": "sessions", + "entityType": "tables" + }, + { + "name": "tickets", + "entityType": "tables" + }, + { + "name": "ticket_attachments", + "entityType": "tables" + }, + { + "name": "ticket_messages", + "entityType": "tables" + }, + { + "name": "ticket_participants", + "entityType": "tables" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": true, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "actors" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "discord_id", + "entityType": "columns", + "table": "actors" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "display_name", + "entityType": "columns", + "table": "actors" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "username", + "entityType": "columns", + "table": "actors" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "avatar", + "entityType": "columns", + "table": "actors" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "moderator", + "entityType": "columns", + "table": "actors" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "created_at", + "entityType": "columns", + "table": "actors" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "updated_at", + "entityType": "columns", + "table": "actors" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "deleted_at", + "entityType": "columns", + "table": "actors" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "user_id", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "access_token", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "refresh_token", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "scope", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "token_type", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "expires_at", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "created_at", + "entityType": "columns", + "table": "sessions" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": true, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "anonymous_id", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "status", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "channel_id", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "close_reason", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "private_notes", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "opened_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "closed_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "opened_by", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "open_reason", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "subject", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "claimed_by", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "claimed_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "thanked_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "warned_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "last_message_at", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "has_moderator_message", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "has_author_message", + "entityType": "columns", + "table": "tickets" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": true, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "public_id", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "message_id", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "ticket_id", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "actor_id", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "file_name", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "file_type", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "file_size", + "entityType": "columns", + "table": "ticket_attachments" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": true, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "public_id", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "message_id", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "ticket_id", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "actor_id", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "content", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "actor_role", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "created_at", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "edited_at", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "deleted_at", + "entityType": "columns", + "table": "ticket_messages" + }, + { + "type": "integer", + "notNull": false, + "autoincrement": true, + "default": null, + "generated": null, + "name": "id", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "ticket_id", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "actor_id", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "type": "text", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "role", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "type": "text", + "notNull": false, + "autoincrement": false, + "default": null, + "generated": null, + "name": "reason", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "type": "integer", + "notNull": true, + "autoincrement": false, + "default": null, + "generated": null, + "name": "created_at", + "entityType": "columns", + "table": "ticket_participants" + }, + { + "columns": [ + "user_id" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "NO ACTION", + "nameExplicit": false, + "name": "fk_sessions_user_id_actors_id_fk", + "entityType": "fks", + "table": "sessions" + }, + { + "columns": [ + "opened_by" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "NO ACTION", + "nameExplicit": false, + "name": "fk_tickets_opened_by_actors_id_fk", + "entityType": "fks", + "table": "tickets" + }, + { + "columns": [ + "subject" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "NO ACTION", + "nameExplicit": false, + "name": "fk_tickets_subject_actors_id_fk", + "entityType": "fks", + "table": "tickets" + }, + { + "columns": [ + "claimed_by" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "NO ACTION", + "nameExplicit": false, + "name": "fk_tickets_claimed_by_actors_id_fk", + "entityType": "fks", + "table": "tickets" + }, + { + "columns": [ + "message_id" + ], + "tableTo": "ticket_messages", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_attachments_message_id_ticket_messages_id_fk", + "entityType": "fks", + "table": "ticket_attachments" + }, + { + "columns": [ + "ticket_id" + ], + "tableTo": "tickets", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_attachments_ticket_id_tickets_id_fk", + "entityType": "fks", + "table": "ticket_attachments" + }, + { + "columns": [ + "actor_id" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_attachments_actor_id_actors_id_fk", + "entityType": "fks", + "table": "ticket_attachments" + }, + { + "columns": [ + "ticket_id" + ], + "tableTo": "tickets", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_messages_ticket_id_tickets_id_fk", + "entityType": "fks", + "table": "ticket_messages" + }, + { + "columns": [ + "actor_id" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_messages_actor_id_actors_id_fk", + "entityType": "fks", + "table": "ticket_messages" + }, + { + "columns": [ + "ticket_id" + ], + "tableTo": "tickets", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_participants_ticket_id_tickets_id_fk", + "entityType": "fks", + "table": "ticket_participants" + }, + { + "columns": [ + "actor_id" + ], + "tableTo": "actors", + "columnsTo": [ + "id" + ], + "onUpdate": "NO ACTION", + "onDelete": "CASCADE", + "nameExplicit": false, + "name": "fk_ticket_participants_actor_id_actors_id_fk", + "entityType": "fks", + "table": "ticket_participants" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "actors_pk", + "table": "actors", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "sessions_pk", + "table": "sessions", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "tickets_pk", + "table": "tickets", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "ticket_attachments_pk", + "table": "ticket_attachments", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "ticket_messages_pk", + "table": "ticket_messages", + "entityType": "pks" + }, + { + "columns": [ + "id" + ], + "nameExplicit": false, + "name": "ticket_participants_pk", + "table": "ticket_participants", + "entityType": "pks" + }, + { + "columns": [ + { + "value": "ticket_id", + "isExpression": false + } + ], + "isUnique": false, + "where": null, + "origin": "manual", + "name": "ticket_attachments_ticket_idx", + "entityType": "indexes", + "table": "ticket_attachments" + }, + { + "columns": [ + { + "value": "actor_id", + "isExpression": false + } + ], + "isUnique": false, + "where": null, + "origin": "manual", + "name": "ticket_attachments_actor_idx", + "entityType": "indexes", + "table": "ticket_attachments" + }, + { + "columns": [ + { + "value": "public_id", + "isExpression": false + } + ], + "isUnique": false, + "where": null, + "origin": "manual", + "name": "ticket_attachments_public_id_idx", + "entityType": "indexes", + "table": "ticket_attachments" + }, + { + "columns": [ + { + "value": "ticket_id", + "isExpression": false + } + ], + "isUnique": false, + "where": null, + "origin": "manual", + "name": "ticket_messages_ticket_idx", + "entityType": "indexes", + "table": "ticket_messages" + }, + { + "columns": [ + { + "value": "actor_id", + "isExpression": false + } + ], + "isUnique": false, + "where": null, + "origin": "manual", + "name": "ticket_messages_actor_idx", + "entityType": "indexes", + "table": "ticket_messages" + }, + { + "columns": [ + { + "value": "public_id", + "isExpression": false + } + ], + "isUnique": false, + "where": null, + "origin": "manual", + "name": "ticket_messages_public_id_idx", + "entityType": "indexes", + "table": "ticket_messages" + }, + { + "columns": [ + { + "value": "ticket_id", + "isExpression": false + } + ], + "isUnique": false, + "where": null, + "origin": "manual", + "name": "ticket_participants_ticket_idx", + "entityType": "indexes", + "table": "ticket_participants" + }, + { + "columns": [ + { + "value": "actor_id", + "isExpression": false + } + ], + "isUnique": false, + "where": null, + "origin": "manual", + "name": "ticket_participants_actor_idx", + "entityType": "indexes", + "table": "ticket_participants" + }, + { + "columns": [ + { + "value": "role", + "isExpression": false + } + ], + "isUnique": false, + "where": null, + "origin": "manual", + "name": "ticket_participants_role_idx", + "entityType": "indexes", + "table": "ticket_participants" + }, + { + "columns": [ + "discord_id" + ], + "nameExplicit": false, + "name": "actors_discord_id_unique", + "entityType": "uniques", + "table": "actors" + } + ], + "renames": [] +}
A pkgs/db/src/schemas/actors.ts

@@ -0,0 +1,32 @@

+import * as s from "drizzle-orm/sqlite-core"; + +export const actors = s.sqliteTable("actors", { + id: s.integer("id").primaryKey({ autoIncrement: true }), + + discordId: s.text("discord_id").unique(), + displayName: s.text("display_name"), + username: s.text("username"), + avatar: s.text("avatar"), + + moderator: s.integer("moderator", { mode: "boolean" }), + + createdAt: s.integer("created_at", { mode: "timestamp" }).notNull(), + updatedAt: s.integer("updated_at", { mode: "timestamp" }).notNull(), + deletedAt: s.integer("deleted_at", { mode: "timestamp" }), +}); + +export const sessions = s.sqliteTable("sessions", { + id: s.text("id").primaryKey(), + userId: s + .integer("user_id") + .notNull() + .references(() => actors.id), + + accessToken: s.text("access_token").notNull(), + refreshToken: s.text("refresh_token").notNull(), + scope: s.text("scope"), + tokenType: s.text("token_type"), + + expiresAt: s.integer("expires_at", { mode: "timestamp" }).notNull(), + createdAt: s.integer("created_at", { mode: "timestamp" }).notNull(), +});
M pkgs/db/src/schemas/index.tspkgs/db/src/schemas/index.ts

@@ -1,48 +1,3 @@

-import { defineRelations } from "drizzle-orm"; -import * as s from "drizzle-orm/sqlite-core"; - -export const actors = s.sqliteTable("actors", { - id: s.integer("id").primaryKey({ autoIncrement: true }), - - discordId: s.text("discord_id").unique(), - displayName: s.text("display_name"), - username: s.text("username"), - avatar: s.text("avatar"), - - moderator: s.integer("moderator", { mode: "boolean" }), - - createdAt: s.integer("created_at", { mode: "timestamp" }).notNull(), - updatedAt: s.integer("updated_at", { mode: "timestamp" }).notNull(), - deletedAt: s.integer("deleted_at", { mode: "timestamp" }), -}); - -export const sessions = s.sqliteTable("sessions", { - id: s.text("id").primaryKey(), - userId: s - .integer("user_id") - .notNull() - .references(() => actors.id), - - accessToken: s.text("access_token").notNull(), - refreshToken: s.text("refresh_token").notNull(), - scope: s.text("scope"), - tokenType: s.text("token_type"), - - expiresAt: s.integer("expires_at", { mode: "timestamp" }).notNull(), - createdAt: s.integer("created_at", { mode: "timestamp" }).notNull(), -}); - -export const actorRelationships = defineRelations({ actors, sessions }, (r) => ({ - actors: { - sessions: r.many.sessions({ - from: r.actors.id, - to: r.sessions.userId, - }), - }, - sessions: { - actor: r.one.actors({ - from: r.sessions.userId, - to: r.actors.id, - }), - }, -})); +export * from "./actors"; +export * from "./tickets"; +export * from "./relations";
A pkgs/db/src/schemas/relations.ts

@@ -0,0 +1,128 @@

+import { defineRelations } from "drizzle-orm"; +import { actors, sessions } from "./actors"; +import { ticket, ticketParticipants, ticketMessages, ticketAttachments } from "./tickets"; + +export const schemaRelations = defineRelations( + { + actors, + sessions, + ticket, + ticketParticipants, + ticketMessages, + ticketAttachments, + }, + (r) => ({ + actors: { + sessions: r.many.sessions({ + from: r.actors.id, + to: r.sessions.userId, + }), + + openedTickets: r.many.ticket({ + from: r.actors.id, + to: r.ticket.openedBy, + alias: "ticket_opened_by", + }), + subjectTickets: r.many.ticket({ + from: r.actors.id, + to: r.ticket.subject, + alias: "ticket_subject", + }), + claimedTickets: r.many.ticket({ + from: r.actors.id, + to: r.ticket.claimedBy, + alias: "ticket_claimed_by", + }), + ticketParticipants: r.many.ticketParticipants({ + from: r.actors.id, + to: r.ticketParticipants.actorId, + }), + ticketMessages: r.many.ticketMessages({ + from: r.actors.id, + to: r.ticketMessages.actorId, + }), + ticketAttachments: r.many.ticketAttachments({ + from: r.actors.id, + to: r.ticketAttachments.actorId, + }), + }, + + sessions: { + actor: r.one.actors({ + from: r.sessions.userId, + to: r.actors.id, + }), + }, + + ticket: { + opener: r.one.actors({ + from: r.ticket.openedBy, + to: r.actors.id, + alias: "ticket_opened_by", + }), + subjectActor: r.one.actors({ + from: r.ticket.subject, + to: r.actors.id, + alias: "ticket_subject", + }), + claimedByActor: r.one.actors({ + from: r.ticket.claimedBy, + to: r.actors.id, + alias: "ticket_claimed_by", + }), + participants: r.many.ticketParticipants({ + from: r.ticket.id, + to: r.ticketParticipants.ticketId, + }), + messages: r.many.ticketMessages({ + from: r.ticket.id, + to: r.ticketMessages.ticketId, + }), + attachments: r.many.ticketAttachments({ + from: r.ticket.id, + to: r.ticketAttachments.ticketId, + }), + }, + + ticketParticipants: { + ticket: r.one.ticket({ + from: r.ticketParticipants.ticketId, + to: r.ticket.id, + }), + actor: r.one.actors({ + from: r.ticketParticipants.actorId, + to: r.actors.id, + }), + }, + + ticketMessages: { + ticket: r.one.ticket({ + from: r.ticketMessages.ticketId, + to: r.ticket.id, + }), + actor: r.one.actors({ + from: r.ticketMessages.actorId, + to: r.actors.id, + }), + attachments: r.many.ticketAttachments({ + from: r.ticketMessages.id, + to: r.ticketAttachments.messageId, + }), + }, + + ticketAttachments: { + ticket: r.one.ticket({ + from: r.ticketAttachments.ticketId, + to: r.ticket.id, + }), + actor: r.one.actors({ + from: r.ticketAttachments.actorId, + to: r.actors.id, + }), + message: r.one.ticketMessages({ + from: r.ticketAttachments.messageId, + to: r.ticketMessages.id, + }), + }, + }), +);
A pkgs/db/src/schemas/tickets.ts

@@ -0,0 +1,120 @@

+import * as s from "drizzle-orm/sqlite-core"; +import { actors } from "./actors"; + +export const ticket = s.sqliteTable("tickets", { + id: s.integer("id").primaryKey({ autoIncrement: true }), + anonymousId: s.text("anonymous_id").notNull(), + + status: s.text("status").notNull(), + channelId: s.text("channel_id").notNull(), + + closeReason: s.text("close_reason"), + privateNotes: s.text("private_notes"), + + openedAt: s.integer("opened_at", { mode: "timestamp" }).notNull(), + closedAt: s.integer("closed_at", { mode: "timestamp" }), + + /** the actor that opened the ticket, may be the same as the subject */ + openedBy: s + .integer("opened_by") + .notNull() + .references(() => actors.id), + openReason: s.text("open_reason"), + + /** the actor who is the subject of the ticket */ + subject: s + .integer("subject") + .notNull() + .references(() => actors.id), + + claimedBy: s.integer("claimed_by").references(() => actors.id), + claimedAt: s.integer("claimed_at", { mode: "timestamp" }), + + thankedAt: s.integer("thanked_at", { mode: "timestamp" }), + warnedAt: s.integer("warned_at", { mode: "timestamp" }), + lastMessageAt: s.integer("last_message_at", { mode: "timestamp" }), + + hasModeratorMessage: s.integer("has_moderator_message", { mode: "boolean" }), + hasAuthorMessage: s.integer("has_author_message", { mode: "boolean" }), +}); + +export const ticketParticipants = s.sqliteTable( + "ticket_participants", + { + id: s.integer("id").primaryKey({ autoIncrement: true }), + ticketId: s + .integer("ticket_id") + .notNull() + .references(() => ticket.id, { onDelete: "cascade" }), + actorId: s + .integer("actor_id") + .notNull() + .references(() => actors.id, { onDelete: "cascade" }), + + role: s.text("role", { enum: ["participant", "moderator", "subject"] }).notNull(), + reason: s.text("reason"), + + createdAt: s.integer("created_at", { mode: "timestamp" }).notNull(), + }, + (table) => [ + s.index("ticket_participants_ticket_idx").on(table.ticketId), + s.index("ticket_participants_actor_idx").on(table.actorId), + s.index("ticket_participants_role_idx").on(table.role), + ], +); + +export const ticketMessages = s.sqliteTable( + "ticket_messages", + { + id: s.integer("id").primaryKey({ autoIncrement: true }), + publicId: s.text("public_id").notNull(), + messageId: s.text("message_id"), + + ticketId: s + .integer("ticket_id") + .notNull() + .references(() => ticket.id, { onDelete: "cascade" }), + actorId: s + .integer("actor_id") + .notNull() + .references(() => actors.id, { onDelete: "cascade" }), + + content: s.text("content").notNull(), + actorRole: s.text("actor_role", { enum: ["participant", "moderator", "subject"] }).notNull(), + + createdAt: s.integer("created_at", { mode: "timestamp" }).notNull(), + editedAt: s.integer("edited_at", { mode: "timestamp" }), + deletedAt: s.integer("deleted_at", { mode: "timestamp" }), + }, + (table) => [ + s.index("ticket_messages_ticket_idx").on(table.ticketId), + s.index("ticket_messages_actor_idx").on(table.actorId), + s.index("ticket_messages_public_id_idx").on(table.publicId), + ], +); + +export const ticketAttachments = s.sqliteTable( + "ticket_attachments", + { + id: s.integer("id").primaryKey({ autoIncrement: true }), + publicId: s.text("public_id").notNull(), + messageId: s.integer("message_id").references(() => ticketMessages.id, { onDelete: "cascade" }), + ticketId: s + .integer("ticket_id") + .notNull() + .references(() => ticket.id, { onDelete: "cascade" }), + actorId: s + .integer("actor_id") + .notNull() + .references(() => actors.id, { onDelete: "cascade" }), + + fileName: s.text("file_name").notNull(), + fileType: s.text("file_type").notNull(), + fileSize: s.integer("file_size").notNull(), + }, + (table) => [ + s.index("ticket_attachments_ticket_idx").on(table.ticketId), + s.index("ticket_attachments_actor_idx").on(table.actorId), + s.index("ticket_attachments_public_id_idx").on(table.publicId), + ], +);