/**
 * Adds `ai_assisted boolean NOT NULL DEFAULT false` to catalog_products so the
 * storefront can render a disclaimer when the product was authored or
 * assisted by AI (F-112).
 *
 * @param {import('node-pg-migrate').MigrationBuilder} pgm
 */
export const up = (pgm) => {
  pgm.sql(
    `ALTER TABLE catalog_products ADD COLUMN IF NOT EXISTS ai_assisted boolean NOT NULL DEFAULT false`,
  );
  pgm.sql(
    `CREATE INDEX IF NOT EXISTS catalog_products_ai_assisted_idx ON catalog_products (ai_assisted) WHERE ai_assisted`,
  );
};

export const down = (pgm) => {
  pgm.sql(`DROP INDEX IF EXISTS catalog_products_ai_assisted_idx`);
  pgm.sql(`ALTER TABLE catalog_products DROP COLUMN IF EXISTS ai_assisted`);
};
