-- Migration 009: nn_page_blocks — Editable homepage content blocks
-- Each block stores encrypted JSON content keyed by block_key
-- The homepage editor reads/writes these, public home.php reads them

CREATE TABLE IF NOT EXISTS nn_page_blocks (
    id          INT AUTO_INCREMENT PRIMARY KEY,
    store_id    INT NOT NULL DEFAULT 1,
    page        VARCHAR(32) NOT NULL DEFAULT 'home',
    block_key   VARCHAR(64) NOT NULL,
    block_type  VARCHAR(32) NOT NULL DEFAULT 'generic',
    content     TEXT NOT NULL,
    sort_order  INT NOT NULL DEFAULT 0,
    is_active   TINYINT(1) NOT NULL DEFAULT 1,
    updated_at  TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE KEY uq_block (store_id, page, block_key)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
