summaryrefslogblamecommitdiff
path: root/makima/migrations/20250114000001_task_checkpoints.sql
blob: 8692466abb421f9b93126deb13eeda699a359553 (plain) (tree)























                                                                                                                     
-- Task checkpoints table for tracking git commit history per task
-- Enables branching from any checkpoint

CREATE TABLE IF NOT EXISTS task_checkpoints (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    task_id UUID NOT NULL REFERENCES tasks(id) ON DELETE CASCADE,
    checkpoint_number INTEGER NOT NULL,
    commit_sha VARCHAR(40) NOT NULL,
    branch_name VARCHAR(255) NOT NULL,
    message TEXT NOT NULL,
    files_changed JSONB,  -- Array of {path, action: 'A'|'M'|'D'}
    lines_added INTEGER DEFAULT 0,
    lines_removed INTEGER DEFAULT 0,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),

    UNIQUE(task_id, checkpoint_number)
);

CREATE INDEX idx_task_checkpoints_task_id ON task_checkpoints(task_id);
CREATE INDEX idx_task_checkpoints_commit_sha ON task_checkpoints(commit_sha);

COMMENT ON TABLE task_checkpoints IS 'Git commit history for tasks, enabling branching from any checkpoint';
COMMENT ON COLUMN task_checkpoints.checkpoint_number IS 'Sequential checkpoint number within this task';
COMMENT ON COLUMN task_checkpoints.files_changed IS 'JSON array of {path, action} for files modified in this commit';