

-- Locations Tabelle (für Multi-Tenant)
CREATE TABLE IF NOT EXISTS `locations` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `name` varchar(100) NOT NULL,
    `subdomain` varchar(50) NOT NULL UNIQUE,
    `database_name` varchar(100) NOT NULL UNIQUE,
    `description` text,
    `contact_email` varchar(100),
    `contact_phone` varchar(20),
    `is_active` tinyint(1) DEFAULT 1,
    `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
    `updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`id`),
    INDEX `idx_subdomain` (`subdomain`),
    INDEX `idx_database_name` (`database_name`),
    INDEX `idx_is_active` (`is_active`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Beispiel-Location (kann gelöscht werden)
INSERT IGNORE INTO `locations` (`name`, `subdomain`, `database_name`, `description`, `contact_email`, `is_active`) 
VALUES ('Hauptstandort', 'main', 'pinrepair_main', 'Hauptstandort für Flipper-Verwaltung', 'admin@pinrepair.com', 1);
