vix orm provides database migration and schema management tooling.
Use it when you want to apply migrations, roll back migrations, inspect migration status, or generate migration files from schema changes.
vix orm is a CLI wrapper around the Vix database migrator tool. It resolves your project, finds the migrations directory, locates the migrator executable, then forwards the command to the database migration engine.
vix orm migrate [options]
vix orm rollback --steps <n> [options]
vix orm status [options]
vix orm makemigrations --new <schema.json> [options]| Subcommand | Purpose |
|---|---|
migrate |
Apply pending migrations. |
rollback |
Roll back applied migrations. |
status |
Show migration status. |
makemigrations |
Generate migration files from schema changes. |
vix orm migrate --db blog_db --dir ./migrations
vix orm status --db blog_db
vix orm rollback --steps 1 --db blog_db
vix orm makemigrations --new ./schema.new.jsonMore complete makemigrations example:
vix orm makemigrations \
--new ./schema.new.json \
--snapshot ./schema.json \
--dir ./migrations \
--name create_users \
--dialect mysqlvix orm helps manage database schema changes.
It can:
apply migration files
roll back migration files
inspect migration state
generate .up.sql and .down.sql files from schema JSON diffs
reuse environment defaults
detect the current project root
detect common migration directories
call the installed Vix database migrator toolvix orm tries to detect the project root automatically.
It looks upward from the current directory and prefers:
a Vix repository root
an application root with CMakePresets.json
an application root with src/ and CMakeLists.txt
a directory with CMakeLists.txtIf detection fails, pass the root manually:
vix orm migrate --project-dir /path/to/project --db blog_dbIf --dir is not provided, Vix tries common migration locations:
migrations
db/migrations
database/migrations
sql/migrations
db/sql
migrations/mysql
migrations/sqliteIf none exists, Vix falls back to:
migrationsFor migrate, rollback, and status, the migrations directory must already exist.
For makemigrations, Vix creates the migrations directory if it is missing.
vix orm calls the Vix database migrator executable.
The preferred tool name is:
vix_db_migratorTool resolution order:
VIX_DB_TOOL
VIX_ORM_TOOL
installed libexec paths
same directory as the vix binary
development build paths
vix_db_migrator from PATHVIX_ORM_TOOL is kept for backward compatibility.
Prefer VIX_DB_TOOL for new setups.
VIX_DB_TOOL=/path/to/vix_db_migrator vix orm migrate --db blog_dbvix orm migrate --db blog_db --dir ./migrationsmigrate applies all pending migration files from the migrations directory.
With environment defaults:
VIX_ORM_DB=blog_db \
VIX_ORM_USER=root \
VIX_ORM_PASS=secret \
vix orm migrate --dir ./migrationsvix orm rollback --steps 1 --db blog_db --dir ./migrationsRollback requires --steps.
vix orm rollback --steps 2 --db blog_db--steps must be greater than or equal to 1.
vix orm status --db blog_db --dir ./migrationsstatus checks the migration setup and prints migration information.
The current implementation prints the migrations directory and a status message from the migrator.
vix orm makemigrations --new ./schema.new.jsonmakemigrations compares a previous schema snapshot with a new schema JSON file.
Default previous snapshot:
schema.jsonDefault migration name:
autoDefault dialect:
mysqlComplete example:
vix orm makemigrations \
--new ./schema.new.json \
--snapshot ./schema.json \
--dir ./migrations \
--name create_users \
--dialect mysqlThis generates files like:
migrations/2026_05_28_130501_create_users.up.sql
migrations/2026_05_28_130501_create_users.down.sqlIt also updates the snapshot file with the new schema.
A typical schema workflow looks like this:
# 1. Edit or generate a new schema file
vim schema.new.json
# 2. Generate migration files
vix orm makemigrations \
--new ./schema.new.json \
--snapshot ./schema.json \
--dir ./migrations \
--name add_users \
--dialect mysql
# 3. Apply migrations
vix orm migrate --db blog_db --dir ./migrations
# 4. Check status
vix orm status --db blog_db --dir ./migrations
# 5. Validate the project
vix check --testsAccepted dialect values:
mysql
sqliteCurrent implementation note:
makemigrations currently generates SQL for mysql only.If --dialect sqlite is passed to makemigrations, the CLI accepts the value, but the generator can still fail because SQLite SQL generation is not implemented yet.
Use MySQL for migration generation today:
vix orm makemigrations \
--new ./schema.new.json \
--dialect mysqlThe migrator uses the database drivers enabled when the tool was built.
If MySQL support is enabled, the migrator uses the MySQL driver.
If SQLite support is enabled instead, the migrator uses the SQLite driver.
If no database driver is enabled, the migrator reports that it was built without DB drivers.
| Option | Description |
|---|---|
--db <name> |
Database name. Overrides VIX_ORM_DB. |
--dir <path> |
Migrations directory. Overrides VIX_ORM_DIR. |
--host <uri> |
MySQL URI. Default is tcp://127.0.0.1:3306. |
--user <name> |
Database user. Default is root. |
--pass <pass> |
Database password. |
--project-dir <path> |
Force project root detection. |
--tool <path> |
Override migrator executable path. |
-h, --help |
Show command help. |
| Option | Description | |
|---|---|---|
--new <path> |
New schema JSON file. Required. | |
--snapshot <path> |
Previous snapshot. Default is schema.json. |
|
--name <label> |
Migration label. Default is auto. |
|
| `--dialect <mysql | sqlite>` | SQL dialect. Default is mysql. |
| Option | Description |
|---|---|
--steps <n> |
Roll back the last N applied migrations. Required. |
| Variable | Description |
|---|---|
VIX_ORM_HOST |
Default database host. Default is tcp://127.0.0.1:3306. |
VIX_ORM_USER |
Default database user. Default is root. |
VIX_ORM_PASS |
Default database password. |
VIX_ORM_DB |
Default database name. Default is vixdb. |
VIX_ORM_DIR |
Default migrations directory. |
VIX_DB_TOOL |
Preferred migrator executable path. |
VIX_ORM_TOOL |
Legacy migrator executable path. |
vix orm migrate --db blog_db --dir ./migrationsvix orm status --db blog_db --dir ./migrationsvix orm rollback --steps 1 --db blog_db --dir ./migrationsvix orm makemigrations \
--new ./schema.new.json \
--snapshot ./schema.json \
--dir ./migrations \
--name create_users \
--dialect mysqlVIX_ORM_DB=blog_db \
VIX_ORM_USER=root \
VIX_ORM_PASS=secret \
vix orm migrate --dir ./migrationsVIX_DB_TOOL=./build/db_build/vix_db_migrator \
vix orm migrate --db blog_db --dir ./migrationsvix orm migrate \
--project-dir /home/me/apps/blog \
--db blog_db \
--dir ./migrations# 1. Generate a migration
vix orm makemigrations \
--new ./schema.new.json \
--snapshot ./schema.json \
--dir ./migrations \
--name add_users \
--dialect mysql
# 2. Review generated SQL
cat ./migrations/*.up.sql
cat ./migrations/*.down.sql
# 3. Apply migrations
vix orm migrate --db blog_db --dir ./migrations
# 4. Check migration status
vix orm status --db blog_db --dir ./migrations
# 5. Validate the project
vix check --testsvix install
vix orm migrate --db blog_db --dir ./migrations
vix check --testsWith environment variables:
VIX_ORM_HOST=tcp://127.0.0.1:3306 \
VIX_ORM_USER=root \
VIX_ORM_PASS=secret \
VIX_ORM_DB=blog_db \
vix orm migrate --dir ./migrationsWrong:
vix orm rollback --db blog_dbCorrect:
vix orm rollback --steps 1 --db blog_dbWrong:
vix orm makemigrations --name create_usersCorrect:
vix orm makemigrations --new ./schema.new.json --name create_usersmakemigrations does not need database connection arguments.
It compares schema files and writes migration files.
vix orm makemigrations --new ./schema.new.jsonThe CLI accepts:
vix orm makemigrations --new ./schema.new.json --dialect sqliteBut SQL generation is currently implemented for MySQL.
Use:
vix orm makemigrations --new ./schema.new.json --dialect mysqlAvoid this when possible:
vix orm migrate --db blog_db --user root --pass secretPrefer environment variables:
VIX_ORM_PASS=secret vix orm migrate --db blog_dbIf project detection fails, use:
vix orm migrate \
--project-dir /path/to/project \
--db blog_db \
--dir ./migrationsFor migrate, rollback, and status, the directory must exist.
mkdir -p migrations
vix orm migrate --db blog_db --dir ./migrationsmakemigrations can create the directory automatically.
Use:
VIX_DB_TOOL=/path/to/vix_db_migrator \
vix orm migrate --db blog_db --dir ./migrationsOr pass it directly:
vix orm migrate \
--tool /path/to/vix_db_migrator \
--db blog_db \
--dir ./migrationsUse:
vix orm migrate \
--project-dir /path/to/project \
--db blog_dbCreate it:
mkdir -p migrationsThen run:
vix orm migrate --db blog_db --dir ./migrationsIf the migrator says it was built without DB drivers, rebuild Vix with the required database driver enabled.
For MySQL:
vix build --with-mysqlFor SQLite:
vix build --with-sqlite| Command | Purpose |
|---|---|
vix db |
Database checks, migrations, and SQLite backup tooling. |
vix build --with-mysql |
Build with MySQL support. |
vix build --with-sqlite |
Build with SQLite support. |
vix check |
Validate the project after migrations. |
vix task |
Automate migration workflows. |
vix env check |
Validate project environment files. |
Continue with peer-to-peer nodes.