{"id":28496311,"url":"https://github.com/fboulnois/migrio","last_synced_at":"2026-03-07T01:35:23.605Z","repository":{"id":295699135,"uuid":"990962517","full_name":"fboulnois/migrio","owner":"fboulnois","description":"A drop-in database migration library in Rust for PostgreSQL","archived":false,"fork":false,"pushed_at":"2025-05-26T23:26:42.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-21T21:14:24.540Z","etag":null,"topics":["async","postgres","postgresql","rust","sql","tokio","tokio-postgres"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fboulnois.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-26T23:21:32.000Z","updated_at":"2025-09-01T18:40:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"9159bf55-81f1-48aa-ad45-0bf1238704c4","html_url":"https://github.com/fboulnois/migrio","commit_stats":null,"previous_names":["fboulnois/migrio"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/fboulnois/migrio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboulnois%2Fmigrio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboulnois%2Fmigrio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboulnois%2Fmigrio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboulnois%2Fmigrio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fboulnois","download_url":"https://codeload.github.com/fboulnois/migrio/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fboulnois%2Fmigrio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30046510,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T10:53:31.691Z","status":"ssl_error","status_checked_at":"2026-03-03T10:53:22.041Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","postgres","postgresql","rust","sql","tokio","tokio-postgres"],"created_at":"2025-06-08T12:07:17.330Z","updated_at":"2026-03-07T01:35:23.556Z","avatar_url":"https://github.com/fboulnois.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# migrio\n\nAn asynchronous database migration library for PostgreSQL.\n\n- `sqlx` is a library for working with databases in Rust and provides a fantastic migration feature which is simple and easy to use. However, it also depends on a lot of crates and is not specifically focused on performance.\n- `tokio-postgres` is an extremely fast PostgreSQL client for Rust built on `tokio` but it does not provide any migration functionality.\n\n`migrio` combines the best of both of these crates. By only focusing on migrations, `migrio` is able to provide a simple way to apply and roll back migrations in your database. It provides a nearly drop-in replacement for the migration functionality of `sqlx`, but is built on top of `tokio-postgres` to minimize dependencies.\n\n## Usage\n\n1. Create a migration directory with SQL files. Each file should be named with a version number and a description, for example:\n\n```sh\nmigrations/\n  ├── 0001_initial.sql\n  ├── 0002_add_column.sql\n  ├── 0003_add_table.up.sql\n  └── 0003_add_table.down.sql\n```\n\n2. Add `migrio` to your `Cargo.toml`:\n\n```toml\n[dependencies]\nmigrio = \"1.0\"\n```\n\n3. Run the migration from your code:\n\n```rust\nuse migrio::Migration;\n\n// let (mut client, connection) = tokio_postgres::connect(...).await?;\n// ...\n\nlet migration = Migration::new(\"migrations\")?;\nmigration.run(\u0026mut client).await?;\n```\n\n## API\n\nThe API and functionality of `migrio` is nearly identical to `sqlx`:\n\n```rust\n// type alias of migrio::Migration\nuse migrio::Migrator;\n\n// create a new migration from the `migration_dir` directory\nlet migration = Migrator::new(migration_dir)?;\n\n// run all migrations\nmigration.run(\u0026mut client).await?;\n\n// roll back migrations up to a specific version\nmigration.undo(\u0026mut client, version).await?;\n```\n\n`migrio` sorts the migrations by version number and applies them in order. If a migration fails, the entire migration is rolled back. Migrations use the following naming scheme for files:\n\n```sh\n{VERSION}_{DESCRIPTION}.sql\n{VERSION}_{DESCRIPTION}.up.sql\n{VERSION}_{DESCRIPTION}.down.sql\n```\n\n`{VERSION}` is a number that represents the order in which the migrations should be applied. `{DESCRIPTION}` is a human-readable description of the migration. `migrio` also supports optional reversible `up` and `down` migrations. When using reversible migrations, each `up` migration should be paired with a corresponding `down` migration. The `down` migrations are applied in reverse order when `undo`ing a migration.\n\n## Development\n\n### Building\n\nTo build the library:\n\n```sh\ncargo build\n```\n\n### Testing\n\nTo run unit tests:\n\n```sh\ncargo test\n```\n\nTo also run integration tests against a PostgreSQL database:\n\n```sh\ndocker compose -f tests/docker-compose.test.yml up -d\ncargo test -- --include-ignored\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffboulnois%2Fmigrio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffboulnois%2Fmigrio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffboulnois%2Fmigrio/lists"}