-- Tabelle für ausstehende Tenant-Registrierungen
CREATE TABLE IF NOT EXISTS `tenant_registrations` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `first_name` varchar(100) NOT NULL,
    `last_name` varchar(100) NOT NULL,
    `email` varchar(255) NOT NULL,
    `location_name` varchar(200) NOT NULL,
    `country` varchar(100) NOT NULL,
    `subdomain` varchar(50) NOT NULL,
    `verification_token` varchar(255) NOT NULL UNIQUE,
    `token_expires_at` timestamp NOT NULL,
    `is_verified` tinyint(1) DEFAULT 0,
    `is_provisioned` tinyint(1) DEFAULT 0,
    `provisioning_error` text NULL,
    `ip_address` varchar(45) NOT NULL,
    `user_agent` text,
    `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
    `verified_at` timestamp NULL,
    `provisioned_at` timestamp NULL,
    PRIMARY KEY (`id`),
    UNIQUE KEY `unique_email` (`email`),
    UNIQUE KEY `unique_subdomain` (`subdomain`),
    UNIQUE KEY `unique_verification_token` (`verification_token`),
    INDEX `idx_verification_token` (`verification_token`),
    INDEX `idx_email` (`email`),
    INDEX `idx_subdomain` (`subdomain`),
    INDEX `idx_token_expires` (`token_expires_at`),
    INDEX `idx_is_verified` (`is_verified`),
    INDEX `idx_is_provisioned` (`is_provisioned`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
