CREATE TABLE IF NOT EXISTS crews (
    id INT AUTO_INCREMENT PRIMARY KEY,
    tenant_id INT NOT NULL,
    owner_user_id INT NOT NULL,
    name VARCHAR(190) NOT NULL,
    lead_user_id INT NOT NULL,
    member_user_ids TEXT NULL,
    skill_tags TEXT NULL,
    availability_days TEXT NULL,
    status VARCHAR(40) NOT NULL DEFAULT 'active',
    created_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL
);

ALTER TABLE jobs ADD COLUMN IF NOT EXISTS assigned_crew_id INT NULL;
