Skip to content

Email for professionals and teams

53.3 KB
Raw Blame
{
  "migrations": [
    {
      "name": "0000_baseline.sql",
      "statements": [
        "CREATE TABLE `agent_chat_messages` (\n\t`id` varchar(191) NOT NULL,\n\t`conversation_id` varchar(191) NOT NULL,\n\t`role` varchar(64) NOT NULL,\n\t`content` longtext NOT NULL,\n\t`tool_name` longtext,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `agent_chat_messages_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `agent_conversations` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`title` longtext NOT NULL DEFAULT ('New conversation'),\n\t`created_at` bigint NOT NULL,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `agent_conversations_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `agent_draft_metadata` (\n\t`draft_id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`origin` varchar(64) NOT NULL,\n\t`source_message_id` varchar(191),\n\t`revision` bigint NOT NULL DEFAULT 1,\n\t`human_edited_at` bigint,\n\t`scheduled_at` bigint,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `agent_draft_metadata_draft_id` PRIMARY KEY(`draft_id`)\n);",
        "CREATE TABLE `agent_jobs` (\n\t`id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`source_message_id` varchar(191) NOT NULL,\n\t`reviewer_user_id` varchar(191) NOT NULL,\n\t`status` varchar(64) NOT NULL DEFAULT 'pending',\n\t`attempts` bigint NOT NULL DEFAULT 0,\n\t`next_attempt_at` bigint NOT NULL,\n\t`lease_until` bigint,\n\t`draft_id` varchar(191),\n\t`reason` longtext,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `agent_jobs_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `agent_jobs_source_idx` UNIQUE(`mailbox_id`,`source_message_id`)\n);",
        "CREATE TABLE `agent_send_approvals` (\n\t`id` varchar(191) NOT NULL,\n\t`draft_id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`request_key_id` varchar(191),\n\t`revision` bigint NOT NULL,\n\t`payload_hash` longtext NOT NULL,\n\t`status` varchar(64) NOT NULL DEFAULT 'pending',\n\t`claimed_at` bigint,\n\t`message_id` longtext,\n\t`expires_at` bigint NOT NULL,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `agent_send_approvals_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `ai_usage` (\n\t`id` varchar(191) NOT NULL,\n\t`created_at` bigint NOT NULL,\n\t`provider` longtext NOT NULL,\n\t`model` longtext NOT NULL,\n\t`source` longtext NOT NULL,\n\t`input_tokens` bigint,\n\t`output_tokens` bigint,\n\t`cost_usd_micros` bigint,\n\tCONSTRAINT `ai_usage_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `api_keys` (\n\t`id` varchar(191) NOT NULL,\n\t`kind` varchar(64) NOT NULL DEFAULT 'legacy',\n\t`user_id` varchar(191) NOT NULL,\n\t`name` longtext NOT NULL,\n\t`prefix` longtext NOT NULL,\n\t`key_hash` longtext NOT NULL,\n\t`scopes` longtext NOT NULL,\n\t`mailbox_scope_enabled` boolean NOT NULL DEFAULT false,\n\t`created_at` bigint NOT NULL,\n\t`last_used_at` bigint,\n\tCONSTRAINT `api_keys_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `app_settings` (\n\t`id` varchar(191) NOT NULL,\n\t`app_name` longtext NOT NULL DEFAULT ('Mailflare'),\n\t`outbound_attachment_max_mb` bigint NOT NULL DEFAULT 25,\n\t`drive_storage_limit_bytes` bigint,\n\t`resend_api_key` longtext,\n\t`aws_config` longtext,\n\t`ses_receiving` longtext,\n\t`resend_webhook_id` longtext,\n\t`resend_webhook_secret` longtext,\n\t`icon_key` longtext,\n\t`agent_enabled` boolean NOT NULL DEFAULT true,\n\t`agent_provider` varchar(64),\n\t`agent_preset` varchar(64),\n\t`agent_base_url` longtext,\n\t`agent_api_key` longtext,\n\t`agent_model` longtext,\n\t`agent_model_rates` longtext,\n\t`spamhaus_dqs_key` longtext,\n\t`abusech_auth_key` longtext,\n\t`spam_domain_age_check` boolean NOT NULL DEFAULT true,\n\t`spam_brands` longtext,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `app_settings_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `audit_logs` (\n\t`id` varchar(191) NOT NULL,\n\t`actor_user_id` varchar(191),\n\t`target_user_id` varchar(191),\n\t`mailbox_id` varchar(191),\n\t`message_id` varchar(191),\n\t`action` longtext NOT NULL,\n\t`metadata` longtext,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `audit_logs_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `auto_reply_deliveries` (\n\t`id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`recipient` varchar(320) NOT NULL,\n\t`sent_at` bigint NOT NULL,\n\tCONSTRAINT `auto_reply_deliveries_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `auto_reply_deliveries_mailbox_recipient_idx` UNIQUE(`mailbox_id`,`recipient`)\n);",
        "CREATE TABLE `backup_settings` (\n\t`id` varchar(191) NOT NULL,\n\t`enabled` boolean NOT NULL DEFAULT true,\n\t`schedule_type` varchar(64) NOT NULL DEFAULT 'daily',\n\t`schedule_value` bigint,\n\t`retention_enabled` boolean NOT NULL DEFAULT false,\n\t`retention_days` bigint NOT NULL DEFAULT 30,\n\t`excluded_table_groups` longtext NOT NULL DEFAULT ('[]'),\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `backup_settings_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `backups` (\n\t`id` varchar(191) NOT NULL,\n\t`status` varchar(64) NOT NULL DEFAULT 'queued',\n\t`trigger` varchar(64) NOT NULL,\n\t`r2_key` longtext,\n\t`filename` longtext,\n\t`size` bigint,\n\t`error` longtext,\n\t`created_by_user_id` varchar(191),\n\t`created_at` bigint NOT NULL,\n\t`started_at` bigint,\n\t`completed_at` bigint,\n\tCONSTRAINT `backups_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `booking_events` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`name` longtext NOT NULL,\n\t`slug` varchar(191) NOT NULL DEFAULT '',\n\t`description` longtext NOT NULL DEFAULT (''),\n\t`color` longtext NOT NULL DEFAULT ('#2563eb'),\n\t`host_ids` longtext NOT NULL DEFAULT ('[]'),\n\t`duration_minutes` bigint NOT NULL,\n\t`location` longtext NOT NULL DEFAULT (''),\n\t`weekdays` longtext NOT NULL DEFAULT ('[1,2,3,4,5]'),\n\t`start_time` longtext NOT NULL DEFAULT ('09:00'),\n\t`end_time` longtext NOT NULL DEFAULT ('17:00'),\n\t`time_ranges` longtext NOT NULL DEFAULT ('[{\"startTime\":\"09:00\",\"endTime\":\"17:00\"}]'),\n\t`time_zone` longtext NOT NULL DEFAULT ('UTC'),\n\t`enabled` boolean NOT NULL DEFAULT true,\n\t`created_at` bigint NOT NULL,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `booking_events_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `booking_events_user_slug_idx` UNIQUE(`user_id`,`slug`)\n);",
        "CREATE TABLE `calendar_events` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191),\n\t`title` longtext NOT NULL,\n\t`description` longtext NOT NULL DEFAULT (''),\n\t`location` longtext NOT NULL DEFAULT (''),\n\t`attendees` longtext NOT NULL DEFAULT ('[]'),\n\t`color` longtext NOT NULL DEFAULT ('blue'),\n\t`repeat` varchar(64) NOT NULL DEFAULT 'none',\n\t`repeat_days` longtext NOT NULL DEFAULT ('[]'),\n\t`repeat_anchor_day` bigint,\n\t`repeat_until` bigint,\n\t`excluded_occurrences` longtext NOT NULL DEFAULT ('[]'),\n\t`time_zone` longtext,\n\t`starts_at` bigint NOT NULL,\n\t`ends_at` bigint NOT NULL,\n\t`created_at` bigint NOT NULL,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `calendar_events_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `contacts` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`email` varchar(320) NOT NULL,\n\t`display_name` longtext,\n\t`avatar_key` longtext,\n\t`source` varchar(64) NOT NULL DEFAULT 'inbound',\n\t`blocked` boolean NOT NULL DEFAULT false,\n\t`remote_content_allowed` boolean NOT NULL DEFAULT false,\n\t`last_seen_at` bigint,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `contacts_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `contacts_user_email_idx` UNIQUE(`user_id`,`email`)\n);",
        "CREATE TABLE `domain_tracking_hosts` (\n\t`domain_id` varchar(191) NOT NULL,\n\t`hostname` varchar(255) NOT NULL,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `domain_tracking_hosts_domain_id` PRIMARY KEY(`domain_id`),\n\tCONSTRAINT `domain_tracking_hosts_hostname_idx` UNIQUE(`hostname`)\n);",
        "CREATE TABLE `domains` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`hostname` varchar(255) NOT NULL,\n\t`zone_id` longtext NOT NULL,\n\t`status` varchar(64) NOT NULL DEFAULT 'pending',\n\t`routing_status` longtext,\n\t`sending_subdomain_tag` longtext,\n\t`sending_provider` varchar(64) NOT NULL DEFAULT 'none',\n\t`receiving_provider` varchar(64) NOT NULL DEFAULT 'cloudflare',\n\t`sending_requested` boolean NOT NULL DEFAULT false,\n\t`sending_enabled` boolean NOT NULL DEFAULT false,\n\t`routing_enabled` boolean NOT NULL DEFAULT false,\n\t`dns_skipped` boolean NOT NULL DEFAULT false,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `domains_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `domains_hostname_idx` UNIQUE(`hostname`)\n);",
        "CREATE TABLE `drive_items` (\n\t`id` varchar(191) NOT NULL,\n\t`owner_id` varchar(191) NOT NULL,\n\t`parent_id` varchar(191),\n\t`kind` varchar(64) NOT NULL,\n\t`name` longtext NOT NULL,\n\t`r2_key` longtext,\n\t`size` bigint NOT NULL DEFAULT 0,\n\t`content_type` longtext NOT NULL DEFAULT ('application/octet-stream'),\n\t`upload_id` longtext,\n\t`upload_part_size` bigint,\n\t`upload_fingerprint` longtext,\n\t`link_token` varchar(191),\n\t`trashed_at` bigint,\n\t`created_at` bigint NOT NULL,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `drive_items_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `drive_items_link_token_idx` UNIQUE(`link_token`)\n);",
        "CREATE TABLE `drive_shares` (\n\t`id` varchar(191) NOT NULL,\n\t`item_id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`role` varchar(64) NOT NULL DEFAULT 'view',\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `drive_shares_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `drive_shares_item_user_idx` UNIQUE(`item_id`,`user_id`)\n);",
        "CREATE TABLE `drive_upload_parts` (\n\t`item_id` varchar(191) NOT NULL,\n\t`part_number` bigint NOT NULL,\n\t`etag` longtext NOT NULL,\n\tCONSTRAINT `drive_upload_parts_idx` UNIQUE(`item_id`,`part_number`)\n);",
        "CREATE TABLE `email_templates` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`name` longtext NOT NULL,\n\t`subject` longtext NOT NULL DEFAULT (''),\n\t`text_body` longtext NOT NULL DEFAULT (''),\n\t`created_at` bigint NOT NULL,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `email_templates_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `folders` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`name` varchar(255) NOT NULL,\n\t`color` longtext NOT NULL DEFAULT ('#2563eb'),\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `folders_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `folders_mailbox_name_idx` UNIQUE(`mailbox_id`,`name`)\n);",
        "CREATE TABLE `follow_ups` (\n\t`id` varchar(191) NOT NULL,\n\t`message_id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`due_at` bigint NOT NULL,\n\t`status` varchar(64) NOT NULL DEFAULT 'pending',\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `follow_ups_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `follow_ups_message_idx` UNIQUE(`message_id`)\n);",
        "CREATE TABLE `import_jobs` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`kind` varchar(64) NOT NULL,\n\t`label` longtext NOT NULL,\n\t`status` varchar(64) NOT NULL DEFAULT 'queued',\n\t`total` bigint NOT NULL DEFAULT 0,\n\t`processed` bigint NOT NULL DEFAULT 0,\n\t`imported` bigint NOT NULL DEFAULT 0,\n\t`skipped` bigint NOT NULL DEFAULT 0,\n\t`spec` longtext NOT NULL,\n\t`cursor` longtext NOT NULL DEFAULT ('{}'),\n\t`errors` longtext NOT NULL DEFAULT ('[]'),\n\t`error_count` bigint NOT NULL DEFAULT 0,\n\t`error` longtext,\n\t`created_at` bigint NOT NULL,\n\t`started_at` bigint,\n\t`updated_at` bigint NOT NULL,\n\t`finished_at` bigint,\n\tCONSTRAINT `import_jobs_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `jmap_change_floor` (\n\t`id` bigint NOT NULL,\n\t`seq` bigint NOT NULL DEFAULT 0,\n\tCONSTRAINT `jmap_change_floor_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `jmap_changes` (\n\t`seq` bigint AUTO_INCREMENT NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`object_type` varchar(64) NOT NULL,\n\t`object_id` longtext NOT NULL,\n\t`thread_id` longtext,\n\t`change` varchar(64) NOT NULL,\n\t`created_at` bigint NOT NULL DEFAULT (unix_timestamp()),\n\tCONSTRAINT `jmap_changes_seq` PRIMARY KEY(`seq`)\n);",
        "CREATE TABLE `jmap_mailbox_revisions` (\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`revision` bigint NOT NULL DEFAULT 0,\n\tCONSTRAINT `jmap_mailbox_revisions_mailbox_id` PRIMARY KEY(`mailbox_id`)\n);",
        "CREATE TABLE `license_settings` (\n\t`id` varchar(191) NOT NULL,\n\t`instance_id` varchar(191) NOT NULL,\n\t`instance_url` longtext,\n\t`license_key_hash` longtext,\n\t`plan` varchar(64) NOT NULL DEFAULT 'community',\n\t`state` varchar(64) NOT NULL DEFAULT 'inactive',\n\t`features` longtext NOT NULL DEFAULT ('[]'),\n\t`seat_limit` bigint DEFAULT 1,\n\t`activated_at` bigint,\n\t`validated_at` bigint,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `license_settings_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `license_settings_instance_id_unique` UNIQUE(`instance_id`)\n);",
        "CREATE TABLE `login_challenges` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`token_hash` varchar(191) NOT NULL,\n\t`expires_at` bigint NOT NULL,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `login_challenges_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `login_challenges_token_hash_unique` UNIQUE(`token_hash`)\n);",
        "CREATE TABLE `mailbox_access` (\n\t`id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`permission` varchar(64) NOT NULL DEFAULT 'read_only',\n\t`created_by_user_id` varchar(191),\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `mailbox_access_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `mailbox_access_mailbox_user_idx` UNIQUE(`mailbox_id`,`user_id`)\n);",
        "CREATE TABLE `mailbox_agent_settings` (\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`enabled` boolean NOT NULL DEFAULT false,\n\t`model_id` longtext,\n\t`auto_draft_enabled` boolean NOT NULL DEFAULT false,\n\t`reviewer_user_id` varchar(191),\n\t`instructions` longtext NOT NULL DEFAULT (''),\n\t`daily_limit` bigint NOT NULL DEFAULT 25,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `mailbox_agent_settings_mailbox_id` PRIMARY KEY(`mailbox_id`)\n);",
        "CREATE TABLE `mailbox_aliases` (\n\t`id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`domain_id` varchar(191) NOT NULL,\n\t`local_part` varchar(191) NOT NULL,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `mailbox_aliases_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `mailbox_aliases_address_idx` UNIQUE(`domain_id`,`local_part`)\n);",
        "CREATE TABLE `mailboxes` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`domain_id` varchar(191) NOT NULL,\n\t`local_part` varchar(191) NOT NULL,\n\t`display_name` longtext,\n\t`signature` longtext,\n\t`auto_reply_enabled` boolean NOT NULL DEFAULT false,\n\t`auto_reply_subject` longtext NOT NULL DEFAULT ('Out of office'),\n\t`auto_reply_body` longtext NOT NULL DEFAULT (''),\n\t`avatar_key` longtext,\n\t`type` varchar(64) NOT NULL DEFAULT 'personal',\n\t`use_all_domains` boolean NOT NULL DEFAULT true,\n\t`disabled` boolean NOT NULL DEFAULT false,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `mailboxes_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `mailboxes_address_idx` UNIQUE(`domain_id`,`local_part`)\n);",
        "CREATE TABLE `mcp_key_mailboxes` (\n\t`key_id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\tCONSTRAINT `mcp_key_mailbox_idx` UNIQUE(`key_id`,`mailbox_id`)\n);",
        "CREATE TABLE `message_attachments` (\n\t`id` varchar(191) NOT NULL,\n\t`message_id` varchar(191) NOT NULL,\n\t`filename` longtext NOT NULL,\n\t`content_type` longtext NOT NULL,\n\t`size` bigint NOT NULL,\n\t`disposition` varchar(64) NOT NULL DEFAULT 'attachment',\n\t`content_id` longtext,\n\t`r2_key` varchar(512) NOT NULL,\n\t`trashed_at` bigint,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `message_attachments_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `message_attachments_r2_key_unique` UNIQUE(`r2_key`)\n);",
        "CREATE TABLE `message_opens` (\n\t`id` varchar(191) NOT NULL,\n\t`token` varchar(191) NOT NULL,\n\t`opened_at` bigint NOT NULL,\n\t`client` longtext,\n\t`device` longtext,\n\t`country` longtext,\n\t`city` longtext,\n\t`automated` boolean NOT NULL DEFAULT false,\n\tCONSTRAINT `message_opens_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `message_tracking` (\n\t`token` varchar(191) NOT NULL,\n\t`message_id` varchar(191) NOT NULL,\n\t`open_count` bigint NOT NULL DEFAULT 0,\n\t`first_opened_at` bigint,\n\t`last_opened_at` bigint,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `message_tracking_token` PRIMARY KEY(`token`),\n\tCONSTRAINT `message_tracking_message_idx` UNIQUE(`message_id`)\n);",
        "CREATE TABLE `messages` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191),\n\t`direction` varchar(64) NOT NULL,\n\t`provider_message_id` varchar(512),\n\t`folder_id` varchar(191),\n\t`from_addr` longtext NOT NULL,\n\t`to_addr` longtext NOT NULL,\n\t`cc_addr` longtext,\n\t`bcc_addr` longtext,\n\t`reply_to` longtext,\n\t`subject` longtext,\n\t`snippet` longtext,\n\t`text_body` longtext,\n\t`html_body` longtext,\n\t`raw_r2_key` varchar(512),\n\t`status` varchar(191) NOT NULL DEFAULT 'received',\n\t`read` boolean NOT NULL DEFAULT false,\n\t`starred` boolean NOT NULL DEFAULT false,\n\t`snoozed_until` bigint,\n\t`thread_id` varchar(512),\n\t`in_reply_to` longtext,\n\t`references_header` longtext,\n\t`spam_score` bigint,\n\t`spam_verdict` varchar(64),\n\t`spam_signals` longtext,\n\t`spam_analyzed_at` bigint,\n\t`spam_analysis_error` longtext,\n\t`trashed_at` bigint,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `messages_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `mfa_recovery_codes` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`code_hash` varchar(191) NOT NULL,\n\t`used_at` bigint,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `mfa_recovery_codes_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `mfa_recovery_codes_code_hash_unique` UNIQUE(`code_hash`)\n);",
        "CREATE TABLE `outbound_jobs` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`message_id` varchar(191),\n\t`status` varchar(64) NOT NULL DEFAULT 'queued',\n\t`payload` longtext NOT NULL,\n\t`error` longtext,\n\t`scheduled_at` bigint,\n\t`created_at` bigint NOT NULL,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `outbound_jobs_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `password_reset_tokens` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`token_hash` varchar(191) NOT NULL,\n\t`expires_at` bigint NOT NULL,\n\t`used_at` bigint,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `password_reset_tokens_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `password_reset_tokens_token_hash_unique` UNIQUE(`token_hash`)\n);",
        "CREATE TABLE `push_devices` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`api_key_id` varchar(191) NOT NULL,\n\t`platform` varchar(64) NOT NULL,\n\t`token` varchar(191) NOT NULL,\n\t`environment` varchar(64) NOT NULL DEFAULT 'production',\n\t`topic` longtext NOT NULL,\n\t`public_key` longtext,\n\t`previews` boolean NOT NULL DEFAULT true,\n\t`client_ref` longtext,\n\t`created_at` bigint NOT NULL,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `push_devices_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `push_devices_platform_token_user_idx` UNIQUE(`platform`,`token`,`user_id`)\n);",
        "CREATE TABLE `push_subscriptions` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`session_id` varchar(191) NOT NULL,\n\t`endpoint` varchar(512) NOT NULL,\n\t`p256dh` longtext NOT NULL,\n\t`auth` longtext NOT NULL,\n\t`created_at` bigint NOT NULL,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `push_subscriptions_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `push_subscriptions_endpoint_idx` UNIQUE(`endpoint`)\n);",
        "CREATE TABLE `routing_rules` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`domain_id` varchar(191) NOT NULL,\n\t`scope` varchar(64) NOT NULL DEFAULT 'mailbox',\n\t`name` longtext,\n\t`enabled` boolean NOT NULL DEFAULT true,\n\t`pattern` longtext NOT NULL,\n\t`match_field` varchar(64) NOT NULL DEFAULT 'email',\n\t`match_operator` varchar(64) NOT NULL DEFAULT 'contains',\n\t`match_value` longtext NOT NULL DEFAULT (''),\n\t`mailbox_id` varchar(191),\n\t`folder_id` varchar(191),\n\t`action` varchar(64) NOT NULL DEFAULT 'store',\n\t`forward_to` longtext,\n\t`keep_copy` boolean NOT NULL DEFAULT false,\n\t`reject_reason` longtext,\n\t`priority` bigint NOT NULL DEFAULT 0,\n\t`last_matched_at` bigint,\n\t`match_count` bigint NOT NULL DEFAULT 0,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `routing_rules_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `sessions` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`token_hash` varchar(191) NOT NULL,\n\t`expires_at` bigint NOT NULL,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `sessions_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `sessions_token_hash_unique` UNIQUE(`token_hash`)\n);",
        "CREATE TABLE `shared_attachment_links` (\n\t`id` varchar(191) NOT NULL,\n\t`attachment_id` varchar(191) NOT NULL,\n\t`expires_at` bigint NOT NULL,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `shared_attachment_links_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `shared_attachment_links_attachment_id_unique` UNIQUE(`attachment_id`)\n);",
        "CREATE TABLE `spam_feedback` (\n\t`message_id` varchar(191) NOT NULL,\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`actor_user_id` varchar(191),\n\t`classification` varchar(64) NOT NULL,\n\t`training_tokens` longtext NOT NULL,\n\t`reputation_keys` longtext NOT NULL,\n\t`tokenizer_version` bigint NOT NULL DEFAULT 1,\n\t`created_at` bigint NOT NULL,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `spam_feedback_message_id` PRIMARY KEY(`message_id`)\n);",
        "CREATE TABLE `spam_reputation` (\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`type` varchar(64) NOT NULL,\n\t`key` varchar(191) NOT NULL,\n\t`messages_seen` bigint NOT NULL DEFAULT 0,\n\t`spam_count` bigint NOT NULL DEFAULT 0,\n\t`ham_count` bigint NOT NULL DEFAULT 0,\n\t`first_seen_at` bigint NOT NULL,\n\t`last_seen_at` bigint NOT NULL,\n\tCONSTRAINT `spam_reputation_mailbox_type_key_idx` UNIQUE(`mailbox_id`,`type`,`key`)\n);",
        "CREATE TABLE `spam_token_stats` (\n\t`mailbox_id` varchar(191) NOT NULL,\n\t`token` varchar(191) NOT NULL,\n\t`spam_count` bigint NOT NULL DEFAULT 0,\n\t`ham_count` bigint NOT NULL DEFAULT 0,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `spam_token_stats_mailbox_token_idx` UNIQUE(`mailbox_id`,`token`)\n);",
        "CREATE TABLE `user_compose_preferences` (\n\t`user_id` varchar(191) NOT NULL,\n\t`track_opens_default` boolean NOT NULL DEFAULT false,\n\t`undo_send_seconds` bigint NOT NULL DEFAULT 15,\n\t`updated_at` bigint NOT NULL,\n\tCONSTRAINT `user_compose_preferences_user_id` PRIMARY KEY(`user_id`)\n);",
        "CREATE TABLE `users` (\n\t`id` varchar(191) NOT NULL,\n\t`email` varchar(320) NOT NULL,\n\t`reset_email` longtext,\n\t`forwarding_email` longtext,\n\t`password_hash` longtext NOT NULL,\n\t`name` longtext NOT NULL,\n\t`booking_username` varchar(191),\n\t`time_zone` longtext,\n\t`avatar_key` longtext,\n\t`role` varchar(64) NOT NULL DEFAULT 'user',\n\t`is_primary_admin` boolean NOT NULL DEFAULT false,\n\t`disabled` boolean NOT NULL DEFAULT false,\n\t`can_manage_mailboxes` boolean NOT NULL DEFAULT false,\n\t`can_manage_domains` boolean NOT NULL DEFAULT false,\n\t`can_manage_users` boolean NOT NULL DEFAULT false,\n\t`keyboard_shortcuts_enabled` boolean NOT NULL DEFAULT true,\n\t`spam_protection_enabled` boolean NOT NULL DEFAULT true,\n\t`trash_retention_days` bigint,\n\t`show_full_recipient_addresses` boolean NOT NULL DEFAULT false,\n\t`remote_content_mode` varchar(64) NOT NULL DEFAULT 'allow',\n\t`totp_secret` longtext,\n\t`totp_enabled` boolean NOT NULL DEFAULT false,\n\t`totp_confirmed_at` bigint,\n\t`last_sign_in_at` bigint,\n\t`deleted_at` bigint,\n\t`created_by_user_id` varchar(191),\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `users_id` PRIMARY KEY(`id`),\n\tCONSTRAINT `users_email_unique` UNIQUE(`email`),\n\tCONSTRAINT `users_booking_username_idx` UNIQUE(`booking_username`)\n);",
        "CREATE TABLE `webhook_deliveries` (\n\t`id` varchar(191) NOT NULL,\n\t`webhook_id` varchar(191) NOT NULL,\n\t`event_type` longtext NOT NULL,\n\t`payload` longtext NOT NULL,\n\t`status` varchar(191) NOT NULL DEFAULT 'pending',\n\t`attempts` bigint NOT NULL DEFAULT 0,\n\t`response_status` bigint,\n\t`error` longtext,\n\t`duration_ms` bigint,\n\t`last_attempt_at` bigint,\n\t`next_retry_at` bigint,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `webhook_deliveries_id` PRIMARY KEY(`id`)\n);",
        "CREATE TABLE `webhooks` (\n\t`id` varchar(191) NOT NULL,\n\t`user_id` varchar(191) NOT NULL,\n\t`description` longtext,\n\t`url` longtext NOT NULL,\n\t`secret` longtext NOT NULL,\n\t`events` longtext NOT NULL,\n\t`enabled` boolean NOT NULL DEFAULT true,\n\t`max_attempts` bigint NOT NULL DEFAULT 5,\n\t`created_at` bigint NOT NULL,\n\tCONSTRAINT `webhooks_id` PRIMARY KEY(`id`)\n);",
        "ALTER TABLE `agent_chat_messages` ADD CONSTRAINT `agent_chat_messages_conversation_id_agent_conversations_id_fk` FOREIGN KEY (`conversation_id`) REFERENCES `agent_conversations`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `agent_conversations` ADD CONSTRAINT `agent_conversations_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `agent_conversations` ADD CONSTRAINT `agent_conversations_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `agent_draft_metadata` ADD CONSTRAINT `agent_draft_metadata_draft_id_messages_id_fk` FOREIGN KEY (`draft_id`) REFERENCES `messages`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `agent_draft_metadata` ADD CONSTRAINT `agent_draft_metadata_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `agent_draft_metadata` ADD CONSTRAINT `agent_draft_metadata_source_message_id_messages_id_fk` FOREIGN KEY (`source_message_id`) REFERENCES `messages`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `agent_jobs` ADD CONSTRAINT `agent_jobs_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `agent_jobs` ADD CONSTRAINT `agent_jobs_source_message_id_messages_id_fk` FOREIGN KEY (`source_message_id`) REFERENCES `messages`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `agent_jobs` ADD CONSTRAINT `agent_jobs_reviewer_user_id_users_id_fk` FOREIGN KEY (`reviewer_user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `agent_jobs` ADD CONSTRAINT `agent_jobs_draft_id_messages_id_fk` FOREIGN KEY (`draft_id`) REFERENCES `messages`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `agent_send_approvals` ADD CONSTRAINT `agent_send_approvals_draft_id_messages_id_fk` FOREIGN KEY (`draft_id`) REFERENCES `messages`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `agent_send_approvals` ADD CONSTRAINT `agent_send_approvals_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `agent_send_approvals` ADD CONSTRAINT `agent_send_approvals_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `agent_send_approvals` ADD CONSTRAINT `agent_send_approvals_request_key_id_api_keys_id_fk` FOREIGN KEY (`request_key_id`) REFERENCES `api_keys`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `api_keys` ADD CONSTRAINT `api_keys_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `audit_logs` ADD CONSTRAINT `audit_logs_actor_user_id_users_id_fk` FOREIGN KEY (`actor_user_id`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `audit_logs` ADD CONSTRAINT `audit_logs_target_user_id_users_id_fk` FOREIGN KEY (`target_user_id`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `audit_logs` ADD CONSTRAINT `audit_logs_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `audit_logs` ADD CONSTRAINT `audit_logs_message_id_messages_id_fk` FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `auto_reply_deliveries` ADD CONSTRAINT `auto_reply_deliveries_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `backups` ADD CONSTRAINT `backups_created_by_user_id_users_id_fk` FOREIGN KEY (`created_by_user_id`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `booking_events` ADD CONSTRAINT `booking_events_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `calendar_events` ADD CONSTRAINT `calendar_events_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `calendar_events` ADD CONSTRAINT `calendar_events_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `contacts` ADD CONSTRAINT `contacts_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `domain_tracking_hosts` ADD CONSTRAINT `domain_tracking_hosts_domain_id_domains_id_fk` FOREIGN KEY (`domain_id`) REFERENCES `domains`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `domains` ADD CONSTRAINT `domains_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `drive_items` ADD CONSTRAINT `drive_items_owner_id_users_id_fk` FOREIGN KEY (`owner_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `drive_shares` ADD CONSTRAINT `drive_shares_item_id_drive_items_id_fk` FOREIGN KEY (`item_id`) REFERENCES `drive_items`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `drive_shares` ADD CONSTRAINT `drive_shares_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `drive_upload_parts` ADD CONSTRAINT `drive_upload_parts_item_id_drive_items_id_fk` FOREIGN KEY (`item_id`) REFERENCES `drive_items`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `email_templates` ADD CONSTRAINT `email_templates_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `folders` ADD CONSTRAINT `folders_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `folders` ADD CONSTRAINT `folders_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `follow_ups` ADD CONSTRAINT `follow_ups_message_id_messages_id_fk` FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `follow_ups` ADD CONSTRAINT `follow_ups_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `import_jobs` ADD CONSTRAINT `import_jobs_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `import_jobs` ADD CONSTRAINT `import_jobs_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `login_challenges` ADD CONSTRAINT `login_challenges_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `mailbox_access` ADD CONSTRAINT `mailbox_access_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `mailbox_access` ADD CONSTRAINT `mailbox_access_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `mailbox_access` ADD CONSTRAINT `mailbox_access_created_by_user_id_users_id_fk` FOREIGN KEY (`created_by_user_id`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `mailbox_agent_settings` ADD CONSTRAINT `mailbox_agent_settings_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `mailbox_agent_settings` ADD CONSTRAINT `mailbox_agent_settings_reviewer_user_id_users_id_fk` FOREIGN KEY (`reviewer_user_id`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `mailbox_aliases` ADD CONSTRAINT `mailbox_aliases_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `mailbox_aliases` ADD CONSTRAINT `mailbox_aliases_domain_id_domains_id_fk` FOREIGN KEY (`domain_id`) REFERENCES `domains`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `mailboxes` ADD CONSTRAINT `mailboxes_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `mailboxes` ADD CONSTRAINT `mailboxes_domain_id_domains_id_fk` FOREIGN KEY (`domain_id`) REFERENCES `domains`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `mcp_key_mailboxes` ADD CONSTRAINT `mcp_key_mailboxes_key_id_api_keys_id_fk` FOREIGN KEY (`key_id`) REFERENCES `api_keys`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `mcp_key_mailboxes` ADD CONSTRAINT `mcp_key_mailboxes_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `message_attachments` ADD CONSTRAINT `message_attachments_message_id_messages_id_fk` FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `message_opens` ADD CONSTRAINT `message_opens_token_message_tracking_token_fk` FOREIGN KEY (`token`) REFERENCES `message_tracking`(`token`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `message_tracking` ADD CONSTRAINT `message_tracking_message_id_messages_id_fk` FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `messages` ADD CONSTRAINT `messages_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `messages` ADD CONSTRAINT `messages_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `messages` ADD CONSTRAINT `messages_folder_id_folders_id_fk` FOREIGN KEY (`folder_id`) REFERENCES `folders`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `mfa_recovery_codes` ADD CONSTRAINT `mfa_recovery_codes_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `outbound_jobs` ADD CONSTRAINT `outbound_jobs_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `outbound_jobs` ADD CONSTRAINT `outbound_jobs_message_id_messages_id_fk` FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `password_reset_tokens` ADD CONSTRAINT `password_reset_tokens_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `push_devices` ADD CONSTRAINT `push_devices_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `push_devices` ADD CONSTRAINT `push_devices_api_key_id_api_keys_id_fk` FOREIGN KEY (`api_key_id`) REFERENCES `api_keys`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `push_subscriptions` ADD CONSTRAINT `push_subscriptions_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `push_subscriptions` ADD CONSTRAINT `push_subscriptions_session_id_sessions_id_fk` FOREIGN KEY (`session_id`) REFERENCES `sessions`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `routing_rules` ADD CONSTRAINT `routing_rules_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `routing_rules` ADD CONSTRAINT `routing_rules_domain_id_domains_id_fk` FOREIGN KEY (`domain_id`) REFERENCES `domains`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `routing_rules` ADD CONSTRAINT `routing_rules_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `routing_rules` ADD CONSTRAINT `routing_rules_folder_id_folders_id_fk` FOREIGN KEY (`folder_id`) REFERENCES `folders`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `sessions` ADD CONSTRAINT `sessions_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `shared_attachment_links` ADD CONSTRAINT `shared_attachment_links_attachment_id_message_attachments_id_fk` FOREIGN KEY (`attachment_id`) REFERENCES `message_attachments`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `spam_feedback` ADD CONSTRAINT `spam_feedback_message_id_messages_id_fk` FOREIGN KEY (`message_id`) REFERENCES `messages`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `spam_feedback` ADD CONSTRAINT `spam_feedback_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `spam_feedback` ADD CONSTRAINT `spam_feedback_actor_user_id_users_id_fk` FOREIGN KEY (`actor_user_id`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `spam_reputation` ADD CONSTRAINT `spam_reputation_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `spam_token_stats` ADD CONSTRAINT `spam_token_stats_mailbox_id_mailboxes_id_fk` FOREIGN KEY (`mailbox_id`) REFERENCES `mailboxes`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `user_compose_preferences` ADD CONSTRAINT `user_compose_preferences_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `users` ADD CONSTRAINT `users_created_by_user_id_users_id_fk` FOREIGN KEY (`created_by_user_id`) REFERENCES `users`(`id`) ON DELETE set null ON UPDATE no action;",
        "ALTER TABLE `webhook_deliveries` ADD CONSTRAINT `webhook_deliveries_webhook_id_webhooks_id_fk` FOREIGN KEY (`webhook_id`) REFERENCES `webhooks`(`id`) ON DELETE cascade ON UPDATE no action;",
        "ALTER TABLE `webhooks` ADD CONSTRAINT `webhooks_user_id_users_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE cascade ON UPDATE no action;",
        "CREATE INDEX `agent_chat_messages_conversation_idx` ON `agent_chat_messages` (`conversation_id`,`created_at`);",
        "CREATE INDEX `agent_conversations_owner_idx` ON `agent_conversations` (`user_id`,`mailbox_id`,`updated_at`);",
        "CREATE INDEX `agent_conversations_mailbox_idx` ON `agent_conversations` (`mailbox_id`);",
        "CREATE INDEX `agent_draft_meta_source_msg_idx` ON `agent_draft_metadata` (`source_message_id`);",
        "CREATE INDEX `agent_draft_metadata_mailbox_idx` ON `agent_draft_metadata` (`mailbox_id`);",
        "CREATE INDEX `agent_jobs_due_idx` ON `agent_jobs` (`status`,`next_attempt_at`);",
        "CREATE INDEX `agent_jobs_source_message_idx` ON `agent_jobs` (`source_message_id`);",
        "CREATE INDEX `agent_jobs_draft_idx` ON `agent_jobs` (`draft_id`);",
        "CREATE INDEX `agent_jobs_reviewer_idx` ON `agent_jobs` (`reviewer_user_id`);",
        "CREATE INDEX `agent_send_approvals_user_idx` ON `agent_send_approvals` (`user_id`,`status`);",
        "CREATE INDEX `agent_send_approvals_delivery_idx` ON `agent_send_approvals` (`draft_id`);",
        "CREATE INDEX `agent_send_approvals_request_key_idx` ON `agent_send_approvals` (`request_key_id`);",
        "CREATE INDEX `agent_send_approvals_mailbox_idx` ON `agent_send_approvals` (`mailbox_id`);",
        "CREATE INDEX `agent_send_approvals_draft_idx` ON `agent_send_approvals` (`draft_id`);",
        "CREATE INDEX `ai_usage_created_idx` ON `ai_usage` (`created_at`);",
        "CREATE INDEX `api_keys_user_idx` ON `api_keys` (`user_id`);",
        "CREATE INDEX `audit_logs_actor_idx` ON `audit_logs` (`actor_user_id`);",
        "CREATE INDEX `audit_logs_mailbox_idx` ON `audit_logs` (`mailbox_id`);",
        "CREATE INDEX `audit_logs_created_idx` ON `audit_logs` (`created_at`);",
        "CREATE INDEX `audit_logs_message_id_idx` ON `audit_logs` (`message_id`);",
        "CREATE INDEX `audit_logs_target_user_idx` ON `audit_logs` (`target_user_id`);",
        "CREATE INDEX `auto_reply_deliveries_sent_idx` ON `auto_reply_deliveries` (`sent_at`);",
        "CREATE INDEX `backups_created_idx` ON `backups` (`created_at`);",
        "CREATE INDEX `backups_status_idx` ON `backups` (`status`);",
        "CREATE INDEX `backups_created_by_idx` ON `backups` (`created_by_user_id`);",
        "CREATE INDEX `booking_events_user_idx` ON `booking_events` (`user_id`);",
        "CREATE INDEX `calendar_events_user_starts_idx` ON `calendar_events` (`user_id`,`starts_at`);",
        "CREATE INDEX `calendar_events_mailbox_idx` ON `calendar_events` (`mailbox_id`);",
        "CREATE INDEX `contacts_user_idx` ON `contacts` (`user_id`);",
        "CREATE INDEX `domains_user_idx` ON `domains` (`user_id`);",
        "CREATE INDEX `drive_items_owner_parent_idx` ON `drive_items` (`owner_id`,`parent_id`);",
        "CREATE INDEX `drive_shares_user_idx` ON `drive_shares` (`user_id`);",
        "CREATE INDEX `email_templates_user_idx` ON `email_templates` (`user_id`);",
        "CREATE INDEX `folders_user_idx` ON `folders` (`user_id`);",
        "CREATE INDEX `folders_mailbox_idx` ON `folders` (`mailbox_id`);",
        "CREATE INDEX `follow_ups_status_due_idx` ON `follow_ups` (`status`,`due_at`);",
        "CREATE INDEX `follow_ups_user_status_idx` ON `follow_ups` (`user_id`,`status`);",
        "CREATE INDEX `import_jobs_user_idx` ON `import_jobs` (`user_id`,`created_at`);",
        "CREATE INDEX `import_jobs_status_idx` ON `import_jobs` (`status`,`updated_at`);",
        "CREATE INDEX `jmap_changes_mailbox_seq_idx` ON `jmap_changes` (`mailbox_id`,`seq`);",
        "CREATE INDEX `login_challenges_user_idx` ON `login_challenges` (`user_id`);",
        "CREATE INDEX `mailbox_access_user_idx` ON `mailbox_access` (`user_id`);",
        "CREATE INDEX `mailbox_access_mailbox_idx` ON `mailbox_access` (`mailbox_id`);",
        "CREATE INDEX `mailbox_access_created_by_idx` ON `mailbox_access` (`created_by_user_id`);",
        "CREATE INDEX `mailbox_agent_settings_reviewer_idx` ON `mailbox_agent_settings` (`reviewer_user_id`);",
        "CREATE INDEX `mailbox_aliases_mailbox_idx` ON `mailbox_aliases` (`mailbox_id`);",
        "CREATE INDEX `mailboxes_user_idx` ON `mailboxes` (`user_id`);",
        "CREATE INDEX `mcp_key_mailboxes_mailbox_idx` ON `mcp_key_mailboxes` (`mailbox_id`);",
        "CREATE INDEX `message_attachments_message_idx` ON `message_attachments` (`message_id`);",
        "CREATE INDEX `message_opens_token_idx` ON `message_opens` (`token`,`opened_at`);",
        "CREATE INDEX `messages_user_created_idx` ON `messages` (`user_id`,`created_at`);",
        "CREATE INDEX `messages_mailbox_idx` ON `messages` (`mailbox_id`);",
        "CREATE INDEX `messages_folder_idx` ON `messages` (`folder_id`);",
        "CREATE INDEX `messages_thread_idx` ON `messages` (`mailbox_id`,`thread_id`);",
        "CREATE INDEX `messages_provider_message_idx` ON `messages` (`mailbox_id`,`provider_message_id`);",
        "CREATE INDEX `messages_raw_r2_key_idx` ON `messages` (`raw_r2_key`);",
        "CREATE INDEX `messages_trashed_at_idx` ON `messages` (`trashed_at`);",
        "CREATE INDEX `messages_inbox_page_idx` ON `messages` (`mailbox_id`,`status`,`folder_id`,`created_at`);",
        "CREATE INDEX `messages_thread_key_idx` ON `messages` (`mailbox_id`,`status`,`folder_id`,`created_at`);",
        "CREATE INDEX `messages_mailbox_thread_key_idx` ON `messages` (`mailbox_id`);",
        "CREATE INDEX `messages_nav_cover_idx` ON `messages` (`mailbox_id`,`status`,`folder_id`,`created_at`);",
        "CREATE INDEX `messages_counts_cover_idx` ON `messages` (`mailbox_id`,`folder_id`,`direction`,`status`,`read`,`starred`,`snoozed_until`);",
        "CREATE INDEX `messages_conv_cover_idx` ON `messages` (`mailbox_id`,`status`,`created_at`,`id`,`snoozed_until`);",
        "CREATE INDEX `mfa_recovery_codes_user_idx` ON `mfa_recovery_codes` (`user_id`);",
        "CREATE INDEX `outbound_jobs_user_idx` ON `outbound_jobs` (`user_id`);",
        "CREATE INDEX `outbound_jobs_message_idx` ON `outbound_jobs` (`message_id`);",
        "CREATE INDEX `password_reset_tokens_user_idx` ON `password_reset_tokens` (`user_id`);",
        "CREATE INDEX `push_devices_user_idx` ON `push_devices` (`user_id`);",
        "CREATE INDEX `push_devices_api_key_idx` ON `push_devices` (`api_key_id`);",
        "CREATE INDEX `push_subscriptions_user_idx` ON `push_subscriptions` (`user_id`);",
        "CREATE INDEX `push_subscriptions_session_idx` ON `push_subscriptions` (`session_id`);",
        "CREATE INDEX `routing_rules_domain_scope_idx` ON `routing_rules` (`domain_id`,`scope`,`enabled`);",
        "CREATE INDEX `routing_rules_mailbox_idx` ON `routing_rules` (`mailbox_id`);",
        "CREATE INDEX `routing_rules_priority_idx` ON `routing_rules` (`priority`);",
        "CREATE INDEX `routing_rules_user_idx` ON `routing_rules` (`user_id`);",
        "CREATE INDEX `routing_rules_folder_idx` ON `routing_rules` (`folder_id`);",
        "CREATE INDEX `sessions_user_idx` ON `sessions` (`user_id`);",
        "CREATE INDEX `spam_feedback_mailbox_idx` ON `spam_feedback` (`mailbox_id`);",
        "CREATE INDEX `spam_feedback_actor_user_idx` ON `spam_feedback` (`actor_user_id`);",
        "CREATE INDEX `spam_reputation_mailbox_idx` ON `spam_reputation` (`mailbox_id`);",
        "CREATE INDEX `spam_token_stats_mailbox_idx` ON `spam_token_stats` (`mailbox_id`);",
        "CREATE INDEX `users_created_by_idx` ON `users` (`created_by_user_id`);",
        "CREATE INDEX `webhook_deliveries_webhook_idx` ON `webhook_deliveries` (`webhook_id`,`created_at`);",
        "CREATE INDEX `webhook_deliveries_status_idx` ON `webhook_deliveries` (`status`);",
        "CREATE INDEX `webhooks_user_idx` ON `webhooks` (`user_id`);"
      ]
    },
    {
      "name": "0001_triggers_and_seeds.sql",
      "statements": [
        "INSERT IGNORE INTO backup_settings (id, enabled, schedule_type, retention_enabled, retention_days, updated_at)\nVALUES ('default', false, 'daily', false, 30, unix_timestamp());",
        "INSERT IGNORE INTO app_settings (id, app_name, updated_at)\nVALUES ('default', 'Mailflare', unix_timestamp());",
        "INSERT IGNORE INTO jmap_change_floor (id, seq) VALUES (1, 0);",
        "CREATE TRIGGER messages_trashed_at_bi BEFORE INSERT ON messages FOR EACH ROW\nBEGIN\n\tIF NEW.status IN ('trash', 'spam') THEN\n\t\tSET NEW.trashed_at = unix_timestamp();\n\tEND IF;\nEND;",
        "CREATE TRIGGER messages_trashed_at_bu BEFORE UPDATE ON messages FOR EACH ROW\nBEGIN\n\tIF (NEW.status IN ('trash', 'spam')) <> (OLD.status IN ('trash', 'spam')) THEN\n\t\tSET NEW.trashed_at = IF(NEW.status IN ('trash', 'spam'), unix_timestamp(), NULL);\n\tEND IF;\nEND;",
        "CREATE TRIGGER messages_jmap_ai AFTER INSERT ON messages FOR EACH ROW\nBEGIN\n\tIF NEW.mailbox_id IS NOT NULL THEN\n\t\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (NEW.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\n\t\tINSERT INTO jmap_changes (mailbox_id, object_type, object_id, thread_id, `change`)\n\t\tVALUES (NEW.mailbox_id, 'email', NEW.id, coalesce(NEW.thread_id, NEW.id), 'created');\n\tEND IF;\nEND;",
        "CREATE TRIGGER messages_jmap_au AFTER UPDATE ON messages FOR EACH ROW\nBEGIN\n\tIF NEW.mailbox_id IS NOT NULL THEN\n\t\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (NEW.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\n\tEND IF;\n\tIF OLD.mailbox_id IS NOT NULL AND NOT (OLD.mailbox_id <=> NEW.mailbox_id) THEN\n\t\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (OLD.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\n\tEND IF;\n\tIF OLD.mailbox_id <=> NEW.mailbox_id THEN\n\t\tIF NEW.mailbox_id IS NOT NULL THEN\n\t\t\tINSERT INTO jmap_changes (mailbox_id, object_type, object_id, thread_id, `change`)\n\t\t\tVALUES (NEW.mailbox_id, 'email', NEW.id, coalesce(NEW.thread_id, NEW.id), 'updated');\n\t\tEND IF;\n\tELSE\n\t\tIF OLD.mailbox_id IS NOT NULL THEN\n\t\t\tINSERT INTO jmap_changes (mailbox_id, object_type, object_id, thread_id, `change`)\n\t\t\tVALUES (OLD.mailbox_id, 'email', OLD.id, coalesce(OLD.thread_id, OLD.id), 'destroyed');\n\t\tEND IF;\n\t\tIF NEW.mailbox_id IS NOT NULL THEN\n\t\t\tINSERT INTO jmap_changes (mailbox_id, object_type, object_id, thread_id, `change`)\n\t\t\tVALUES (NEW.mailbox_id, 'email', NEW.id, coalesce(NEW.thread_id, NEW.id), 'created');\n\t\tEND IF;\n\tEND IF;\nEND;",
        "CREATE TRIGGER messages_jmap_ad AFTER DELETE ON messages FOR EACH ROW\nBEGIN\n\tIF OLD.mailbox_id IS NOT NULL THEN\n\t\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (OLD.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\n\t\tINSERT INTO jmap_changes (mailbox_id, object_type, object_id, thread_id, `change`)\n\t\tVALUES (OLD.mailbox_id, 'email', OLD.id, coalesce(OLD.thread_id, OLD.id), 'destroyed');\n\tEND IF;\nEND;",
        "CREATE TRIGGER folders_jmap_ai AFTER INSERT ON folders FOR EACH ROW\nBEGIN\n\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (NEW.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\n\tINSERT INTO jmap_changes (mailbox_id, object_type, object_id, `change`) VALUES (NEW.mailbox_id, 'mailbox', NEW.id, 'created');\nEND;",
        "CREATE TRIGGER folders_jmap_au AFTER UPDATE ON folders FOR EACH ROW\nBEGIN\n\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (NEW.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\n\tIF NOT (OLD.mailbox_id <=> NEW.mailbox_id) THEN\n\t\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (OLD.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\n\t\tINSERT INTO jmap_changes (mailbox_id, object_type, object_id, `change`) VALUES (OLD.mailbox_id, 'mailbox', OLD.id, 'destroyed');\n\tEND IF;\n\tINSERT INTO jmap_changes (mailbox_id, object_type, object_id, `change`)\n\tVALUES (NEW.mailbox_id, 'mailbox', NEW.id, IF(OLD.mailbox_id <=> NEW.mailbox_id, 'updated', 'created'));\nEND;",
        "CREATE TRIGGER folders_jmap_ad AFTER DELETE ON folders FOR EACH ROW\nBEGIN\n\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (OLD.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\n\tINSERT INTO jmap_changes (mailbox_id, object_type, object_id, `change`) VALUES (OLD.mailbox_id, 'mailbox', OLD.id, 'destroyed');\nEND;",
        "CREATE TRIGGER mailboxes_jmap_au AFTER UPDATE ON mailboxes FOR EACH ROW\nBEGIN\n\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (NEW.id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\n\tINSERT INTO jmap_changes (mailbox_id, object_type, object_id, `change`) VALUES (NEW.id, 'mailbox', NEW.id, 'updated');\nEND;",
        "CREATE TRIGGER mailbox_aliases_jmap_ai AFTER INSERT ON mailbox_aliases FOR EACH ROW\nBEGIN\n\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (NEW.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\nEND;",
        "CREATE TRIGGER mailbox_aliases_jmap_au AFTER UPDATE ON mailbox_aliases FOR EACH ROW\nBEGIN\n\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (NEW.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\n\tIF NOT (OLD.mailbox_id <=> NEW.mailbox_id) THEN\n\t\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (OLD.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\n\tEND IF;\nEND;",
        "CREATE TRIGGER mailbox_aliases_jmap_ad AFTER DELETE ON mailbox_aliases FOR EACH ROW\nBEGIN\n\tINSERT INTO jmap_mailbox_revisions (mailbox_id, revision) VALUES (OLD.mailbox_id, 1) ON DUPLICATE KEY UPDATE revision = revision + 1;\nEND;"
      ]
    },
    {
      "name": "0002_calendar_reminders.sql",
      "statements": [
        "ALTER TABLE `calendar_events` ADD `reminder_minutes` bigint;",
        "ALTER TABLE `calendar_events` ADD `last_reminded_start` bigint;"
      ]
    },
    {
      "name": "0003_remote_content_ask.sql",
      "statements": [
        "UPDATE `users` SET `remote_content_mode` = 'ask' WHERE `remote_content_mode` = 'allow';"
      ]
    }
  ]
}