Skip to content

vk migrate

Terminal window
vk migrate [options]
vk migrate status [options]

vk migrate applies pending .sql files from db/migrations/ (and optionally db/seeds/) to the target database. It delegates to @venturekit/data’s built-in pure-SQL runner — no external CLI, no Java install, no schema-generation step. Applied files are tracked in the __vk_migrations and __vk_seeds tables, and their content hash is locked once recorded.

Apply pending schema migrations from db/migrations/.

Terminal window
vk migrate
vk migrate --seed
vk migrate --env prod
OptionDescriptionDefault
-e, --env <env>Target environment (sets VENTURE_STAGE)inherits shell
--seedAlso apply pending seeds from db/seeds/ after migrationsfalse

Show which migrations and seeds have already been applied vs. pending. Read-only — touches no rows.

Terminal window
vk migrate status
vk migrate status --env prod
OptionDescriptionDefault
-e, --env <env>Target environment (sets VENTURE_STAGE)inherits shell
my-app/
├── db/
│ ├── migrations/
│ │ ├── 0001_init.sql
│ │ └── 0002_add_users.sql
│ └── seeds/ # optional
│ └── 0001_demo_data.sql
└── ...

Files are applied in lexical order, one per transaction. Use a numeric prefix (0001_…, 0002_…) so order is unambiguous.

The runner creates two bookkeeping tables on first use:

  • __vk_migrations — schema migrations applied so far (version, hash, applied_at)
  • __vk_seeds — seeds applied so far (same shape)

Once a file is recorded as applied, its content hash is frozen. Editing the file produces a MigrationHashMismatchError on the next run — write a follow-up migration instead.

The runner connects via the granular DB_* vars; DATABASE_URL is parsed into them automatically if set.

VariableDescription
DATABASE_URLPostgres connection string (parsed into DB_HOST/DB_PORT/DB_USER/DB_PASSWORD/DB_NAME/DB_SSL)
DB_HOST / DB_PORT / DB_USER / DB_PASSWORD / DB_NAME / DB_SSLGranular alternative to DATABASE_URL
VENTURE_STAGEEnvironment name (set by --env flag)

.env and .env.local (later wins) are loaded automatically from the current working directory.

MigrationConfig.tool also accepts 'drizzle', 'flyway', 'golang-migrate', and 'prisma' as future-extension points, but those runners are not yet wired up — calling vk migrate with one of those values throws MigrationToolNotImplementedError. For now, use the established tool’s CLI directly:

  • Drizzle Kit — run drizzle-kit migrate against your own drizzle.config.ts from your deploy pipeline.
  • Flyway — use getFlywayEnv() from @venturekit/data to populate FLYWAY_* env vars and invoke the flyway CLI directly.
  • golang-migrate / Prisma Migrate — invoke their CLIs in your deploy pipeline as you would in any other project.