Migrate

Manage database migrations. Migrations are files in the migrations directory, applied in order and tracked in the database, so every environment converges on the same schema. The directory is resolved from the project root, so the commands can be run from any subdirectory.

Syntax

$ vela migrate <command>
  • up - Apply all pending migrations
  • down - Revert the last N applied migrations
  • create - Create a new blank migration
  • collections - Snapshot local collections into a new migration
  • history-sync - Drop history rows whose files no longer exist

Where migrations come from

Most of the time you don’t write them. The generators create collections as they go, and vela generate migration writes the migration for a change to an existing collection. Changes made by hand in the PocketBase admin interface are captured with collections.

On deploy

Pending migrations are applied to the server’s database as part of vela deploy, before the new release is activated. Commit your migrations so they travel with the code.

Types

After changing the schema, run vela sync to regenerate the TypeScript definitions.