import { sql } from 'kysely'; // ADR 0003 §2: Git-Verbindungen (pro Benutzer) und Brew-Verknüpfungen. export const up = async (db)=>{ await sql` CREATE TABLE git_connections ( id uuid PRIMARY KEY DEFAULT uuidv7(), owner_user_id uuid NOT NULL REFERENCES users(id) ON DELETE CASCADE, label text NOT NULL, repo_url text NOT NULL, auth_username text NOT NULL DEFAULT 'git', token_enc text NOT NULL, default_branch text NOT NULL DEFAULT 'main', brew_dir text NOT NULL DEFAULT 'brews', assets_dir text NOT NULL DEFAULT 'assets', created_at timestamptz NOT NULL DEFAULT now(), updated_at timestamptz NOT NULL DEFAULT now(), last_verified_at timestamptz )`.execute(db); await sql`CREATE INDEX git_connections_owner ON git_connections (owner_user_id)`.execute(db); await sql` CREATE TABLE brew_git_links ( brew_id uuid PRIMARY KEY REFERENCES brews(id) ON DELETE CASCADE, connection_id uuid NOT NULL REFERENCES git_connections(id) ON DELETE CASCADE, branch text NOT NULL, path text NOT NULL, last_commit_sha text, last_blob_sha text, last_synced_at timestamptz, last_error text, UNIQUE (connection_id, branch, path) )`.execute(db); }; export const down = async (db)=>{ await sql`DROP TABLE IF EXISTS brew_git_links`.execute(db); await sql`DROP TABLE IF EXISTS git_connections`.execute(db); };