-- NexFusion License Server — Database Schema
-- Run this on your LICENSE SERVER database (NOT the main NexFusion database)
-- =========================================================================

CREATE TABLE IF NOT EXISTS `nf_licenses` (
    `id`             INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    `license_key`    VARCHAR(64)  NOT NULL UNIQUE,
    `customer_name`  VARCHAR(128) NOT NULL DEFAULT '',
    `customer_email` VARCHAR(128) NOT NULL DEFAULT '',
    `allowed_domain` VARCHAR(255) NOT NULL DEFAULT '*',
    `status`         ENUM('Active','Inactive','Expired','Suspended') NOT NULL DEFAULT 'Active',
    `plan`           VARCHAR(64)  NOT NULL DEFAULT 'Standard',
    `addons`         TEXT,
    `expires_at`     DATE         DEFAULT NULL,
    `last_check`     DATETIME     DEFAULT NULL,
    `last_domain`    VARCHAR(255) DEFAULT NULL,
    `last_ip`        VARCHAR(64)  DEFAULT NULL,
    `created_at`     DATETIME     NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `notes`          TEXT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

-- Example license entry
INSERT IGNORE INTO `nf_licenses`
    (`license_key`, `customer_name`, `customer_email`, `allowed_domain`, `status`, `plan`)
VALUES
    ('NEXF-DEMO-0001-XXXX', 'Demo Customer', 'demo@example.com', 'demo.yourdomain.com', 'Active', 'Standard');
