Migration behavior
ViteHub applies committed migrations for you, but it does not generate them. Keep migration authoring on the native ORM toolchain, then let ViteHub apply the committed files during development or build when you enable that behavior.
Commit the migration files you expect ViteHub to apply. ViteHub does not infer schema changes and does not generate new migrations at runtime.
When ViteHub runs migrations
Two shared flags control automatic application:
| Key | Purpose |
|---|---|
applyMigrationsDuringDev | Applies committed migrations when the dev server starts. |
applyMigrationsDuringBuild | Applies committed migrations during build when the runtime supports it. |
Set either flag to false when you want to run the migration step yourself.
import { defineNitroConfig } from 'nitro/config'
export default defineNitroConfig({
modules: ['@vitehub/db/nitro'],
db: {
orm: 'drizzle',
dialect: 'sqlite',
connection: {
url: 'file:.data/db/app.sqlite',
},
applyMigrationsDuringDev: false,
applyMigrationsDuringBuild: false,
},
})
Drizzle migration flow
For Drizzle, ViteHub reads committed SQL migrations from db.drizzle.migrationsDirs and optional SQL files from db.drizzle.queriesPaths. It applies pending migrations first, then applies the configured query files.
import { defineNitroConfig } from 'nitro/config'
export default defineNitroConfig({
modules: ['@vitehub/db/nitro'],
db: {
orm: 'drizzle',
dialect: 'sqlite',
connection: {
url: 'file:.data/db/app.sqlite',
},
drizzle: {
migrationsDirs: ['server/db/migrations'],
queriesPaths: ['server/db/queries/seed.sqlite.sql'],
},
},
})
Prisma migration flow
For Prisma, ViteHub runs the deploy-style migration flow against the configured schema or prisma.config.ts. That keeps runtime behavior aligned with committed Prisma migrations instead of development-only schema pushes.
import { defineNitroConfig } from 'nitro/config'
export default defineNitroConfig({
modules: ['@vitehub/db/nitro'],
db: {
orm: 'prisma',
dialect: 'postgresql',
connection: {
url: process.env.DATABASE_URL,
},
prisma: {
schemaPath: 'prisma/schema.prisma',
clientOutput: '.vitehub/db/prisma-client',
},
},
})
Generate migrations with native tools
Use the native ORM commands to author and review migrations before ViteHub applies them.
pnpm drizzle-kit generate
pnpm drizzle-kit migrate