import type { Migration } from '@/shared/db';

export const reminderMigrations: readonly Migration[] = [
  {
    id: '2026-05-13_reminder_initial',
    sql: `
      CREATE TABLE IF NOT EXISTS macsync.reminders (
        id            UUID PRIMARY KEY DEFAULT gen_random_uuid(),
        device_id     UUID NOT NULL REFERENCES macsync.devices(id) ON DELETE CASCADE,
        external_id   TEXT NOT NULL,
        calendar_id   TEXT NOT NULL,
        title         TEXT,
        notes         TEXT,
        due_date      TIMESTAMPTZ,
        priority      INTEGER,
        is_completed  BOOLEAN NOT NULL DEFAULT false,
        created_at    TIMESTAMPTZ NOT NULL DEFAULT now(),
        modified_at   TIMESTAMPTZ,
        synced_at     TIMESTAMPTZ NOT NULL DEFAULT now(),
        UNIQUE(device_id, external_id)
      );
      CREATE INDEX IF NOT EXISTS idx_reminders_device ON macsync.reminders(device_id);
      CREATE INDEX IF NOT EXISTS idx_reminders_due ON macsync.reminders(due_date);
    `,
  },
];
