Skip to content

feat(db): support PostgreSQL migration schemas - #921

Open
onmax wants to merge 4 commits into
nuxt-hub:mainfrom
onmax:fix/postgresql-atomic-migrations
Open

feat(db): support PostgreSQL migration schemas#921
onmax wants to merge 4 commits into
nuxt-hub:mainfrom
onmax:fix/postgresql-atomic-migrations

Conversation

@onmax

@onmax onmax commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Allow PostgreSQL migration history to live alongside application tables, with atomic migration execution.

hub: {
  db: {
    dialect: 'postgresql',
    migrationsSchema: 'auth'
  }
}
prepare history under advisory lock
  move public._hub_migrations into the configured schema
apply each pending migration under the same lock
  recheck history → run SQL + record migration atomically

The runner and CLI use the configured history table. Existing rows survive relocation; if both history tables exist, execution stops for manual reconciliation. Omitting migrationsSchema keeps the existing search-path behavior. Application tables keep the schemas declared in Drizzle.

This branch also includes the PostgreSQL runtime environment-variable support from #923, allowing deployments to use PG* variables without a connection URL.

Compatibility

  • The configured schema exists before migrations run. SQL that creates it must use CREATE SCHEMA IF NOT EXISTS.
  • Stop old runners before relocating history. Move history back before restarting old code during rollback.
  • PostgreSQL migrations run in one transaction and require PL/pgSQL. Commands such as CREATE INDEX CONCURRENTLY cannot run in this transaction.
  • Other dialects retain their existing behavior. Neon HTTP has not been verified against a live endpoint.

@vercel

vercel Bot commented Aug 12, 2026

Copy link
Copy Markdown

@onmax is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new

pkg-pr-new Bot commented Aug 12, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxthub/core@921

commit: 783861d

@onmax onmax changed the title fix(db): make PostgreSQL migrations atomic feat(db): support PostgreSQL migration schemas Sep 7, 2026
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.

1 participant