CREATE TABLE IF NOT EXISTS hyro_lead_activities (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,

    lead_id BIGINT UNSIGNED NOT NULL,

    activity_type VARCHAR(50) NOT NULL,
    activity_title VARCHAR(190) NOT NULL,
    activity_description TEXT DEFAULT NULL,

    old_value VARCHAR(255) DEFAULT NULL,
    new_value VARCHAR(255) DEFAULT NULL,

    created_by_user_id BIGINT UNSIGNED DEFAULT NULL,
    created_by_name VARCHAR(150) DEFAULT NULL,

    created_at DATETIME NOT NULL,

    PRIMARY KEY (id),

    KEY idx_hyro_lead_activities_lead_id (lead_id),
    KEY idx_hyro_lead_activities_type (activity_type),
    KEY idx_hyro_lead_activities_created_at (created_at),

    CONSTRAINT fk_hyro_lead_activities_lead
        FOREIGN KEY (lead_id)
        REFERENCES hyro_leads (id)
        ON DELETE CASCADE
)
ENGINE=InnoDB
DEFAULT CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
