PRAGMA foreign_keys=OFF;--> statement-breakpoint
CREATE TABLE `__new_ticket_messages` (
	`id` text PRIMARY KEY,
	`message_id` text,
	`ticket_id` text NOT NULL,
	`actor_id` integer NOT NULL,
	`is_private` integer DEFAULT false 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
INSERT INTO `__new_ticket_messages`(`id`, `message_id`, `ticket_id`, `actor_id`, `is_private`, `content`, `actor_role`, `created_at`, `edited_at`, `deleted_at`) SELECT `id`, `message_id`, `ticket_id`, `actor_id`, `is_private`, `content`, `actor_role`, `created_at`, `edited_at`, `deleted_at` FROM `ticket_messages`;--> statement-breakpoint
DROP TABLE `ticket_messages`;--> statement-breakpoint
ALTER TABLE `__new_ticket_messages` RENAME TO `ticket_messages`;--> statement-breakpoint
PRAGMA foreign_keys=ON;--> 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` (`id`);