-- Silo Database Schema
-- Migration: 004_cad_sync_state
-- Date: 2026-01
-- Description: Add CAD file sync tracking for FreeCAD integration

BEGIN;

-- Add columns to track CAD file sync state
ALTER TABLE items ADD COLUMN cad_synced_at TIMESTAMPTZ;
ALTER TABLE items ADD COLUMN cad_file_path TEXT;

-- Index for finding unsynced items
CREATE INDEX idx_items_cad_synced ON items(cad_synced_at) WHERE cad_synced_at IS NULL;

COMMENT ON COLUMN items.cad_synced_at IS 'Timestamp when the item was last synced with a local FreeCAD file';
COMMENT ON COLUMN items.cad_file_path IS 'Expected local path for the CAD file (relative to projects dir)';

COMMIT;
