initSchema() previously read schema.sql from disk at runtime via readFileSync, which broke in compiled Bun binaries and Deno Edge Functions. Now uses a generated schema-embedded.ts constant (run `bun run build:schema` to regenerate). - Removes fs and path imports from postgres-engine.ts and db.ts - Adds scripts/build-schema.sh for one-source-of-truth generation - Adds build:schema npm script Fixes Issue #22 Bug #6. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
16 lines
703 B
Bash
Executable File
16 lines
703 B
Bash
Executable File
#!/bin/bash
|
|
# Generate src/core/schema-embedded.ts from src/schema.sql
|
|
# One source of truth: schema.sql is the canonical file.
|
|
# This script produces a TypeScript constant for use in compiled binaries and Edge Functions.
|
|
set -e
|
|
SCHEMA_FILE="src/schema.sql"
|
|
OUT_FILE="src/core/schema-embedded.ts"
|
|
echo "// AUTO-GENERATED — do not edit. Run: bun run build:schema" > "$OUT_FILE"
|
|
echo "// Source: $SCHEMA_FILE" >> "$OUT_FILE"
|
|
echo "" >> "$OUT_FILE"
|
|
echo "export const SCHEMA_SQL = \`" >> "$OUT_FILE"
|
|
# Escape backticks and dollar signs in the SQL for template literal safety
|
|
sed 's/`/\\`/g; s/\$/\\$/g' "$SCHEMA_FILE" >> "$OUT_FILE"
|
|
echo "\`;" >> "$OUT_FILE"
|
|
echo "Generated $OUT_FILE from $SCHEMA_FILE"
|