Remove database migration blocks

Clean schema without migration code for fresh deployments.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-01-12 08:19:40 +00:00
parent faa54b2e85
commit 00b4934bf6

View File

@@ -43,12 +43,6 @@ CREATE TABLE IF NOT EXISTS item_types (
UNIQUE(cid, actor_id, type, path)
);
-- Add columns if they don't exist (for existing databases)
DO $$ BEGIN
ALTER TABLE item_types ADD COLUMN IF NOT EXISTS filename VARCHAR(255);
ALTER TABLE item_types ADD COLUMN IF NOT EXISTS metadata JSONB DEFAULT '{}';
EXCEPTION WHEN others THEN NULL;
END $$;
-- Pin reasons: one-to-many from item_types
CREATE TABLE IF NOT EXISTS pin_reasons (
@@ -72,30 +66,6 @@ CREATE TABLE IF NOT EXISTS l2_shares (
UNIQUE(cid, actor_id, l2_server, content_type)
);
-- Add activity_id column if it doesn't exist (for existing databases)
DO $$ BEGIN
ALTER TABLE l2_shares ADD COLUMN IF NOT EXISTS activity_id VARCHAR(128);
EXCEPTION WHEN others THEN NULL;
END $$;
-- Migration: rename content_hash to cid (for existing databases)
DO $$ BEGIN
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'cache_items' AND column_name = 'content_hash') THEN
ALTER TABLE cache_items RENAME COLUMN content_hash TO cid;
END IF;
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'item_types' AND column_name = 'content_hash') THEN
ALTER TABLE item_types RENAME COLUMN content_hash TO cid;
END IF;
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'l2_shares' AND column_name = 'content_hash') THEN
ALTER TABLE l2_shares RENAME COLUMN content_hash TO cid;
END IF;
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'storage_pins' AND column_name = 'content_hash') THEN
ALTER TABLE storage_pins RENAME COLUMN content_hash TO cid;
END IF;
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'run_cache' AND column_name = 'output_hash') THEN
ALTER TABLE run_cache RENAME COLUMN output_hash TO output_cid;
END IF;
END $$;
-- Run cache: maps content-addressable run_id to output
-- run_id is a hash of (sorted inputs + recipe), making runs deterministic