Available on non-WebAssembly only.
Expand description
rws db migrate|rollback|status|seed: the project’s migrations and
seeds from the command line (18.30.0).
rws db migrate|rollback|status|seed (18.30.0, #91): the project’s
migrations and seeds from the command line — the same operations, and
for status the same JSON, as the dev MCP server’s migrations,
migrations_run and migrations_rollback_last tools (they share
dev_mcp::db).
- Database:
--database-url <url>, elseDATABASE_URL, else theRWS_DB_*variablesDbPool::from_envreads. URLs are sqlx’s:sqlite:app.db(?mode=rwccreates the file),postgres://…,mysql://…. - Migrations: the
migrationspath of the project’srws.app.toml(migrations/without one), under--dir(default.);--migrations <dir>overrides it. - Seeds:
seeds/beside the migrations directory (migrations/→seeds/,db/migrations/→db/seeds/);--seeds <dir>overrides it. Every*.sqlfile runs, in name order, each in its own transaction, every time — seeDbPool::seed.
The rws binary has the command in every build, but it only reaches a
database when built with a model-* feature (cargo install rust-web-server --features model-sqlite,model-postgres,model-mysql);
otherwise it says so and exits with EXIT_USAGE.
Constants§
- EXIT_
FAILED - The database or a migration failed (connection, SQL error, missing
.down.sql, unreadable directory): see the message. - EXIT_OK
- Done.
- EXIT_
USAGE - Bad arguments, or a build without a database driver.
Functions§
- requested
rws db …asked for: the arguments afterdb.- run
- Run
rws db <args>(the arguments afterdb), writing tooutanderr; answers the exit code (EXIT_OK,EXIT_FAILED,EXIT_USAGE).