-- KYN POS Phase 5 Install Hardening Schema
-- Purpose: Tracks applied migration files and installer activity without storing credentials.
-- Notes: Installer creates this table before running migration files, but this migration keeps the schema documented.

CREATE TABLE IF NOT EXISTS pos_schema_migrations (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
    migration_name VARCHAR(190) NOT NULL,
    migration_checksum CHAR(64) NOT NULL,
    migration_kind ENUM('migration','seed') NOT NULL DEFAULT 'migration',
    status ENUM('applied','skipped','failed') NOT NULL DEFAULT 'applied',
    execution_ms INT UNSIGNED NOT NULL DEFAULT 0,
    message VARCHAR(255) NULL,
    applied_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    PRIMARY KEY (id),
    UNIQUE KEY uq_pos_schema_migrations_name_kind (migration_name, migration_kind),
    KEY idx_pos_schema_migrations_status (status),
    KEY idx_pos_schema_migrations_applied_at (applied_at)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
