-- Run this on an existing database that already has users/accounts/bubbles tables.
CREATE TABLE IF NOT EXISTS egg_timers (
    id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    account_id INT UNSIGNED NOT NULL,
    egg_number TINYINT UNSIGNED NOT NULL,
    duration_seconds INT UNSIGNED NOT NULL,
    started_at DATETIME NOT NULL,
    expires_at DATETIME NOT NULL,
    status ENUM('active', 'stopped', 'completed') NOT NULL DEFAULT 'active',
    created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    KEY idx_eggs_account_status (account_id, status),
    KEY idx_eggs_due (status, expires_at),
    CONSTRAINT fk_eggs_account FOREIGN KEY (account_id) REFERENCES accounts (id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
