migren

Crates.iomigren
lib.rsmigren
version0.1.3
created_at2025-08-08 08:53:41.822228+00
updated_at2025-08-18 21:39:11.475899+00
descriptionSmall migration tool for relational databases.
homepage
repositoryhttps://github.com/saryginrodion/migren
max_upload_size
id1786436
size115,640
Rodion Sarygin (saryginrodion)

documentation

README

migren

Migren is a small migration tool for relational databases.

usage

Firstly, move to directory, where you want to store your migrations (or use -d argument and pass path to this directory)

.env variables

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.

new

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.

top

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.

to

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

Status command can show status of your migrations and database:

migren status
Commit count: 0

cargo fmt