-- CESTÃO VALENÇA V122
-- Notificações push para entregadores.
-- Importar no banco já selecionado no phpMyAdmin.
-- Não cria banco e não executa USE.

CREATE TABLE IF NOT EXISTS driver_device_tokens (
    id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    driver_id BIGINT UNSIGNED NOT NULL,
    fcm_token VARCHAR(4096) NOT NULL,
    platform VARCHAR(30) NOT NULL DEFAULT 'ANDROID',
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NULL,
    UNIQUE KEY uq_driver_device_token (fcm_token(255)),
    INDEX idx_driver_device_driver (driver_id),
    CONSTRAINT fk_driver_device_driver
        FOREIGN KEY (driver_id) REFERENCES drivers(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
