<?php

/**
 * Migration 0011 — Designer-home flag on pages
 *
 * Adds `is_designer_home` to instinctor_pages. A designer can designate exactly
 * one of their own pages as their "home" — that's what `/d/<slug>` serves on
 * instinctor.com (instead of a generic profile card grid). The existing
 * "Set as front page" right-click action in the Page Grid toggles this flag
 * for designer-owned pages; for admin-owned (designer_id NULL) pages it
 * continues to set the global `instinctor_front_page_id` config.
 *
 * Uniqueness per-designer is enforced at the API layer (toggling a new home
 * resets all other pages' flags for the same designer_id) rather than via a
 * unique index so rollback of a single page doesn't strand the designer
 * without a home.
 *
 * @since 2.0.783
 */

if (!defined('ABSPATH')) exit;
return [
    'description' => 'Designer-home flag on pages',

    'up' => [
        "ALTER TABLE {prefix}instinctor_pages
            ADD COLUMN is_designer_home TINYINT(1) NOT NULL DEFAULT 0 AFTER designer_id,
            ADD KEY designer_home (designer_id, is_designer_home)",
    ],

    'down' => [
        "ALTER TABLE {prefix}instinctor_pages
            DROP KEY designer_home,
            DROP COLUMN is_designer_home",
    ],
];
