ALTER TABLE `announcements` ADD COLUMN `is_pinned` boolean DEFAULT false NOT NULL;
CREATE INDEX `announcements_status_pinned_idx` ON `announcements`(`status`, `is_pinned`);

CREATE TABLE `announcement_reads` (
	`id` varchar(128) PRIMARY KEY NOT NULL,
	`announcement_id` varchar(128) NOT NULL,
	`user_id` varchar(128) NOT NULL,
	`read_at` timestamp DEFAULT (now()) NOT NULL,
	CONSTRAINT `announcement_reads_announcement_id_announcements_id_fk` FOREIGN KEY (`announcement_id`) REFERENCES `announcements`(`id`) ON DELETE cascade ON UPDATE no action,
	CONSTRAINT `announcement_reads_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action
);
CREATE INDEX `announcement_reads_announcement_idx` ON `announcement_reads`(`announcement_id`);
CREATE INDEX `announcement_reads_user_idx` ON `announcement_reads`(`user_id`);
CREATE UNIQUE INDEX `announcement_reads_unique_idx` ON `announcement_reads`(`announcement_id`, `user_id`);
