-- ============================================================
-- Migration: add product_links table + footer_links.page column
-- ============================================================

-- 1. 新建 product_links 表
CREATE TABLE IF NOT EXISTS `product_links` (
  `id`            BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
  `asset_id`      BIGINT UNSIGNED NOT NULL,
  `link_text`     VARCHAR(100)    NOT NULL,
  `link_url`      TEXT            NOT NULL,
  `display_order` INT             NOT NULL DEFAULT 0,
  `is_active`     TINYINT(1)      NOT NULL DEFAULT 1,
  `created_at`    DATETIME(3)     NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
  `updated_at`    DATETIME(3)     NOT NULL DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3),
  PRIMARY KEY (`id`),
  INDEX `idx_product_links_asset_id` (`asset_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- 2. footer_links 增加 page 列（如果还没有）
ALTER TABLE `footer_links`
  ADD COLUMN IF NOT EXISTS `page` VARCHAR(50) NOT NULL DEFAULT '' AFTER `id`;
