
CREATE TABLE dev_workspaces (
    id VARCHAR(20) PRIMARY KEY,
    uploaded_name VARCHAR(255) NOT NULL,
    status ENUM('uploaded','built','blocked','approved') DEFAULT 'uploaded',
    extract_files INT DEFAULT 0,
    extract_bytes BIGINT DEFAULT 0,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    updated_at DATETIME NULL
);

CREATE TABLE dev_tasks (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    workspace_id VARCHAR(20) NOT NULL,
    task_text TEXT NOT NULL,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    INDEX(workspace_id)
);

CREATE TABLE dev_builds (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    workspace_id VARCHAR(20) NOT NULL,
    change_plan_json LONGTEXT,
    diff_manifest_json LONGTEXT,
    verifier_json LONGTEXT,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    INDEX(workspace_id)
);

CREATE TABLE dev_architect_reviews (
    id BIGINT AUTO_INCREMENT PRIMARY KEY,
    workspace_id VARCHAR(20) NOT NULL,
    decision ENUM('APPROVE','BLOCK') NOT NULL,
    review_json LONGTEXT,
    created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
    INDEX(workspace_id)
);
