fix(db): rename pgSchema exports to prevent barrel collision

chat/image/mesh modules all exported a generic `const schema`
binding. When packages/db/src/schema/index.ts did `export * from
"./chat"` + `export * from "./image"` + `export * from "./mesh"`,
TypeScript's ambiguous-re-export rule silently dropped the colliding
bindings — drizzle-kit's introspection could not find the pgSchema
instances, so CREATE SCHEMA statements were never emitted. The
migration worked on the prior dev DB only because chat/image already
existed from an earlier turbostarter run; a fresh clone would fail.

pdf.ts already used `pdfSchema` (unique name). Applied the same
pattern everywhere:
- chat.ts:  `export const chatSchema = pgSchema("chat")`
- image.ts: `export const imageSchema = pgSchema("image")`
- mesh.ts:  `export const meshSchema = pgSchema("mesh")`

Also added `CREATE EXTENSION IF NOT EXISTS vector` at the top of the
migration (pgvector is used by pdf.embedding — the generated
migration assumed it was pre-enabled).

Verified end-to-end against a fresh pgvector/pgvector:pg17 container:
`pnpm drizzle-kit migrate` applies cleanly from scratch, all 7 mesh.*
tables + chat/image/pdf/mesh schemas created correctly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Alejandro Gutiérrez
2026-04-04 22:02:09 +01:00
parent 3ab3fbcdf6
commit 8ce8b04e75
6 changed files with 62 additions and 28 deletions

View File

@@ -1,5 +1,12 @@
CREATE EXTENSION IF NOT EXISTS vector;--> statement-breakpoint
CREATE SCHEMA "chat";
--> statement-breakpoint
CREATE SCHEMA "pdf";
--> statement-breakpoint
CREATE SCHEMA "image";
--> statement-breakpoint
CREATE SCHEMA "mesh";
--> statement-breakpoint
CREATE TYPE "public"."credit_transaction_type" AS ENUM('signup', 'purchase', 'usage', 'admin_grant', 'admin_deduct', 'refund', 'promo', 'referral', 'expiry');--> statement-breakpoint
CREATE TYPE "public"."status" AS ENUM('active', 'canceled', 'incomplete', 'incomplete_expired', 'past_due', 'paused', 'trialing', 'unpaid');--> statement-breakpoint
CREATE TYPE "public"."plan" AS ENUM('free', 'premium', 'enterprise');--> statement-breakpoint

View File

@@ -1,5 +1,5 @@
{
"id": "f8d7bddc-1efc-4f4a-8ebb-e8278508656e",
"id": "a1b0192f-d300-48eb-8f1d-e76c65b030dc",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
@@ -2792,7 +2792,10 @@
}
},
"schemas": {
"pdf": "pdf"
"chat": "chat",
"pdf": "pdf",
"image": "image",
"mesh": "mesh"
},
"sequences": {},
"roles": {},

View File

@@ -5,8 +5,8 @@
{
"idx": 0,
"version": "7",
"when": 1775335397081,
"tag": "0000_sloppy_stryfe",
"when": 1775336269295,
"tag": "0000_living_namora",
"breakpoints": true
}
]