How to Write and Run Migrations with sqlx

Generate new migration files with sqlx migrate add and apply them to your database using sqlx migrate run.

You generate migrations by running sqlx migrate add <name> and apply them with sqlx migrate run.

sqlx migrate add create_users_table
sqlx migrate run

The add command creates a new SQL file in the migrations directory, and run executes all pending migrations against your database.