import { Migration } from "@medusajs/framework/mikro-orm/migrations";

export class Migration20260714044201 extends Migration {

  override async up(): Promise<void> {
    this.addSql(`create table if not exists "category_card" ("id" text not null, "homepage_id" text not null, "label" text not null, "sub" text not null, "image_url" text not null, "handle" text not null, "badge" text not null, "bg_color" text not null, "sort_order" integer not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "category_card_pkey" primary key ("id"));`);
    this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_category_card_deleted_at" ON "category_card" ("deleted_at") WHERE deleted_at IS NULL;`);

    this.addSql(`create table if not exists "hero_photo" ("id" text not null, "homepage_id" text not null, "image_url" text not null, "label" text not null, "rotate" text not null, "sort_order" integer not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "hero_photo_pkey" primary key ("id"));`);
    this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_hero_photo_deleted_at" ON "hero_photo" ("deleted_at") WHERE deleted_at IS NULL;`);

    this.addSql(`create table if not exists "homepage" ("id" text not null, "headline" text not null, "subtitle" text not null, "badge_1_text" text not null, "badge_2_text" text not null, "cta_1_label" text not null, "cta_1_link" text not null, "cta_2_label" text not null, "cta_2_link" text not null, "rent_banner_title" text not null, "rent_banner_text" text not null, "rent_banner_cta" text not null, "section_best_deals_heading" text not null, "section_new_arrivals_heading" text not null, "section_partners_heading" text not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "homepage_pkey" primary key ("id"));`);
    this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_homepage_deleted_at" ON "homepage" ("deleted_at") WHERE deleted_at IS NULL;`);

    this.addSql(`create table if not exists "partner" ("id" text not null, "homepage_id" text not null, "name" text not null, "image_url" text not null, "link" text not null, "sort_order" integer not null, "created_at" timestamptz not null default now(), "updated_at" timestamptz not null default now(), "deleted_at" timestamptz null, constraint "partner_pkey" primary key ("id"));`);
    this.addSql(`CREATE INDEX IF NOT EXISTS "IDX_partner_deleted_at" ON "partner" ("deleted_at") WHERE deleted_at IS NULL;`);
  }

  override async down(): Promise<void> {
    this.addSql(`drop table if exists "category_card" cascade;`);

    this.addSql(`drop table if exists "hero_photo" cascade;`);

    this.addSql(`drop table if exists "homepage" cascade;`);

    this.addSql(`drop table if exists "partner" cascade;`);
  }

}
