CREATE TABLE `messages` (
	`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
	`body` text NOT NULL,
	`author` text,
	`created_at` text NOT NULL
);
--> statement-breakpoint
CREATE INDEX `messages_created_idx` ON `messages` (`created_at`,`id`);--> statement-breakpoint
CREATE TABLE `message_reads` (
	`message_id` integer NOT NULL,
	`reader` text NOT NULL,
	`read_at` text NOT NULL,
	PRIMARY KEY(`message_id`, `reader`),
	FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE INDEX `message_reads_reader_idx` ON `message_reads` (`reader`,`read_at`);
