CREATE TABLE IF NOT EXISTS `licenses` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `license_key` VARCHAR(50) NOT NULL UNIQUE,
    `client_name` VARCHAR(100) NOT NULL,
    `allowed_domain` VARCHAR(255) DEFAULT '*',
    `status` ENUM('active', 'suspended', 'expired') DEFAULT 'active',
    `machine_id` VARCHAR(255) DEFAULT NULL,
    `expires_at` DATETIME NOT NULL,
    `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS `activation_logs` (
    `id` INT AUTO_INCREMENT PRIMARY KEY,
    `license_key` VARCHAR(50) NOT NULL,
    `domain` VARCHAR(255) NOT NULL,
    `machine_id` VARCHAR(255) NOT NULL,
    `status` VARCHAR(20),
    `message` TEXT,
    `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
