POSTGRES_SCHEMA_SQL
constPOSTGRES_SCHEMA_SQL: “\nCREATE TABLE IF NOT EXISTS stoma_rate_limits (\n key TEXT PRIMARY KEY,\n count INTEGER NOT NULL DEFAULT 0,\n reset_at BIGINT NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_stoma_rate_limits_reset_at ON stoma_rate_limits (reset_at);\n\nCREATE TABLE IF NOT EXISTS stoma_circuit_breakers (\n key TEXT PRIMARY KEY,\n state TEXT NOT NULL DEFAULT ‘closed’,\n failure_count INTEGER NOT NULL DEFAULT 0,\n success_count INTEGER NOT NULL DEFAULT 0,\n last_failure_time BIGINT NOT NULL DEFAULT 0,\n last_state_change BIGINT NOT NULL DEFAULT 0\n);\n\nCREATE TABLE IF NOT EXISTS stoma_cache (\n key TEXT PRIMARY KEY,\n status INTEGER NOT NULL,\n headers JSONB NOT NULL DEFAULT ’[]’,\n body TEXT NOT NULL DEFAULT ”,\n expires_at BIGINT NOT NULL DEFAULT 0\n);\nCREATE INDEX IF NOT EXISTS idx_stoma_cache_expires_at ON stoma_cache (expires_at);\n”
Defined in: src/adapters/postgres.ts:67
SQL to create the three stoma tables. Run this once against your database
before using the Postgres adapter. All statements use IF NOT EXISTS so
they’re safe to re-run.
Example
Section titled “Example”import { POSTGRES_SCHEMA_SQL } from "@homegrower-club/stoma/adapters/postgres";await pool.query(POSTGRES_SCHEMA_SQL);