-- Add todo steps for cases
CREATE TABLE IF NOT EXISTS sag_todo_steps (
    id SERIAL PRIMARY KEY,
    sag_id INT NOT NULL REFERENCES sag_sager(id) ON DELETE CASCADE,
    title TEXT NOT NULL,
    description TEXT,
    due_date DATE,
    is_done BOOLEAN NOT NULL DEFAULT FALSE,
    created_by_user_id INT,
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    completed_by_user_id INT,
    completed_at TIMESTAMP,
    deleted_at TIMESTAMP
);

CREATE INDEX IF NOT EXISTS idx_sag_todo_steps_sag_id ON sag_todo_steps (sag_id);
CREATE INDEX IF NOT EXISTS idx_sag_todo_steps_is_done ON sag_todo_steps (is_done);
CREATE INDEX IF NOT EXISTS idx_sag_todo_steps_due_date ON sag_todo_steps (due_date);
