| Crates.io | migren |
| lib.rs | migren |
| version | 0.1.3 |
| created_at | 2025-08-08 08:53:41.822228+00 |
| updated_at | 2025-08-18 21:39:11.475899+00 |
| description | Small migration tool for relational databases. |
| homepage | |
| repository | https://github.com/saryginrodion/migren |
| max_upload_size | |
| id | 1786436 |
| size | 115,640 |
Migren is a small migration tool for relational databases.
Firstly, move to directory, where you want to store your migrations (or use -d argument and pass path to this directory)
You need to export this environment variables:
DATABASE_URL="postgres://..." # You can use many drivers. Driver is recognised by schema
RUST_LOG=info # If it is not info, migren will not show you anything except the errors.
You can create .env file and migren will load this variables from it.
Command new is creating new migration files.
# first_migration - name of migration
migren -d migrations new first_migration
It will create files 1_first_migration_up.sql and 1_first_migration_down.sql in migrations directory.
1 - is an migration ID.
In *_up.sql file you define your changes.
In *_down.sql you define your rollback queries.
To update database to the last migration, you can use top command:
migren top
top command uses transactions to update DB, so if anything went wrong, you will stay at the last migration.
With to command you can move to neede migration (you can use it as rollback too)
# Move to migration with id 3
migren to 3
to command uses transactions to update DB, so if anything went wrong, you will stay at the last migration.
Status command can show status of your migrations and database:
migren status