-- Tabela de clientes que compraram a plataforma
CREATE TABLE api_clients (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    email VARCHAR(255) NOT NULL UNIQUE,
    whitelabel VARCHAR(100) NOT NULL,
    status ENUM('active', 'inactive', 'suspended') DEFAULT 'active',
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

-- Inserir alguns clientes de exemplo
INSERT INTO api_clients (name, email, whitelabel, status) VALUES
('Cliente DropPex', 'admin@droppex.io', 'droppex', 'active'),
('Cliente ClickeDrop', 'admin@cliquedrop.com.br', 'cliquedrop', 'active'),
('Cliente SPDrop', 'admin@spdrop.com.br', 'spdrop', 'active'),
('Cliente LoyalCash', 'admin@loyalcash.com.br', 'loyalcash', 'active');

-- Atualizar tabela de tokens para incluir referência ao cliente
ALTER TABLE tokens ADD COLUMN client_id INT NULL AFTER user_id;
ALTER TABLE tokens ADD FOREIGN KEY (client_id) REFERENCES api_clients(id) ON DELETE SET NULL;
