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

export const albumMigrations: readonly Migration[] = [
  {
    id: '2026-04-18_album_initial',
    sql: `
      CREATE TABLE IF NOT EXISTS macsync.albums (
        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,
        name          TEXT NOT NULL DEFAULT '',
        photo_count   INTEGER NOT NULL DEFAULT 0,
        synced_at     TIMESTAMPTZ NOT NULL DEFAULT now(),
        created_at    TIMESTAMPTZ NOT NULL DEFAULT now(),
        updated_at    TIMESTAMPTZ NOT NULL DEFAULT now(),
        UNIQUE(device_id, external_id)
      );
      CREATE INDEX IF NOT EXISTS idx_albums_device ON macsync.albums(device_id);
    `,
  },
];
