Skip to content

feat(db): verify database schema matches code on startup (#352) - #537

Open
sparkysolutions10-pixel wants to merge 1 commit into
Divinity-Labs:mainfrom
sparkysolutions10-pixel:feat/db-schema-startup-verification-352
Open

sparkysolutions10-pixel wants to merge 1 commit into
Divinity-Labs:mainfrom
sparkysolutions10-pixel:feat/db-schema-startup-verification-352

Conversation

@sparkysolutions10-pixel

Copy link
Copy Markdown
Contributor

Closes #352

Summary of Changes

  • Implements assertSchemaValid() in src/db/schemaVerify.ts checking for existence of all required tables and columns against PostgreSQL information_schema on boot.
  • Fails fast and throws DatabaseSchemaMismatchError explicitly naming any missing tables or columns before request handling begins.
  • Integrated into src/index.ts immediately after pgPool.connect().
  • Documents why the project currently utilizes prisma db push instead of migrations, outlining the architectural trade-offs and future transition path to prisma migrate in docs/database-schema.md.
  • Added unit tests in src/__tests__/schemaVerification.test.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Startup does not verify the database schema matches the code

1 participant