<?php

/**
 * Migration 0009 — Page revisions
 *
 * One snapshot row per save (saveElements / saveSettings). Lets designers
 * roll a single page back to a prior state via the page-grid right-click
 * "History" item. Auto-pruned to last 20 per page.
 *
 * Restore is itself snapshotted (it captures current state before overwriting),
 * so a restore is undoable.
 *
 * @since 2.0.776
 */

if (!defined('ABSPATH')) exit;
return [
    'description' => 'Page revisions (per-page editor history)',

    'up' => [
        "CREATE TABLE IF NOT EXISTS {prefix}instinctor_page_revisions (
            id          int unsigned  NOT NULL AUTO_INCREMENT,
            page_id     int unsigned  NOT NULL,
            kind        varchar(20)   NOT NULL DEFAULT 'both',
            elements    longtext      NULL,
            settings    longtext      NULL,
            created_at  datetime      NOT NULL DEFAULT CURRENT_TIMESTAMP,
            PRIMARY KEY (id),
            KEY page_id_created (page_id, created_at)
        ) {charset}",
    ],

    'down' => [
        "DROP TABLE IF EXISTS {prefix}instinctor_page_revisions",
    ],
];
