-- Per-moderator schedule for the "observations awaiting review" digest email.
-- minute_of_day_utc defaults to 720 (12:00 UTC). Moderators with no row here
-- still receive the digest at the default time.

-- CreateTable
CREATE TABLE `moderator_digest_settings` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `enabled` BOOLEAN NOT NULL DEFAULT true,
    `minute_of_day_utc` INTEGER NOT NULL DEFAULT 720,
    `last_sent_at` DATETIME(3) NULL,
    `user_id` INTEGER NOT NULL,
    `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updated_at` DATETIME(3) NOT NULL,

    UNIQUE INDEX `moderator_digest_settings_user_id_key`(`user_id`),
    INDEX `moderator_digest_settings_minute_of_day_utc_idx`(`minute_of_day_utc`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `moderator_digest_settings` ADD CONSTRAINT `moderator_digest_settings_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
