-- Add UUID column to projects table
ALTER TABLE projects ADD COLUMN uuid TEXT;

-- Generate UUIDs for existing projects using a simple pattern
UPDATE projects SET uuid = (
  'proj-' ||
  LOWER(HEX(RANDOMBLOB(4))) || '-' ||
  LOWER(HEX(RANDOMBLOB(2))) || '-' ||
  LOWER(HEX(RANDOMBLOB(2))) || '-' ||
  LOWER(HEX(RANDOMBLOB(2))) || '-' ||
  LOWER(HEX(RANDOMBLOB(6)))
) WHERE uuid IS NULL;

-- Create unique index on uuid
CREATE UNIQUE INDEX IF NOT EXISTS idx_projects_uuid ON projects(uuid);
