{"id":16677807,"url":"https://github.com/jaemk/migrant_lib","last_synced_at":"2025-03-17T00:32:19.879Z","repository":{"id":28039504,"uuid":"115971003","full_name":"jaemk/migrant_lib","owner":"jaemk","description":"Embeddable migration management","archived":false,"fork":false,"pushed_at":"2023-10-19T01:49:20.000Z","size":206,"stargazers_count":23,"open_issues_count":6,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-13T13:27:42.960Z","etag":null,"topics":["database","database-migrations","embedded","migrations","mysql","postgres","rust","sqlite"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaemk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-02T03:32:01.000Z","updated_at":"2022-11-07T03:45:19.000Z","dependencies_parsed_at":"2022-07-27T12:02:20.116Z","dependency_job_id":null,"html_url":"https://github.com/jaemk/migrant_lib","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaemk%2Fmigrant_lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaemk%2Fmigrant_lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaemk%2Fmigrant_lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaemk%2Fmigrant_lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaemk","download_url":"https://codeload.github.com/jaemk/migrant_lib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221669335,"owners_count":16860855,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["database","database-migrations","embedded","migrations","mysql","postgres","rust","sqlite"],"created_at":"2024-10-12T13:27:33.855Z","updated_at":"2024-10-27T11:35:23.120Z","avatar_url":"https://github.com/jaemk.png","language":"Rust","readme":"# migrant_lib\n\n[![Build Status](https://travis-ci.org/jaemk/migrant_lib.svg?branch=master)](https://travis-ci.org/jaemk/migrant_lib)\n[![crates.io:migrant_lib](https://img.shields.io/crates/v/migrant_lib.svg?label=migrant_lib)](https://crates.io/crates/migrant_lib)\n[![docs](https://docs.rs/migrant_lib/badge.svg)](https://docs.rs/migrant_lib)\n\n\u003e Embeddable migration management\n\u003e\n\u003e Also see [`migrant`](https://github.com/jaemk/migrant) CLI\n\n`migrant_lib` allows defining and embedding management of database migrations and\n(connection) configuration in your compiled application.\n\n\n**Available Features:**\n\n| Feature       |    Backend                   |\n|---------------|------------------------------|\n| `d-postgres`  | Enable postgres connectivity |\n| `d-sqlite`    | Enable sqlite connectivity   |\n| `d-mysql`     | Enable mysql connectivity    |\n| `d-all`       | Enable all backends          |\n\n\n*Notes:*\n\n- No features are enabled by default\n- As of `0.20.0` the `d-sqlite` feature does not use `rusqlite`s `bundled` feature.\n  If you would like `sqlite` to be bundled with your application, you will have to\n  include `rusqlite` and enable the `bundled` feature in your project.\n\n\n## Usage\n\n- You must enable the database features relevant to your usecase (`d-postgres` / `d-sqlite` / `d-mysql`).\n- Migrations can be defined as files, string literals, or functions.\n- File migrations can be either read from files at runtime or embedded in your executable at compile time\n  (using [`include_str!`](https://doc.rust-lang.org/std/macro.include_str.html)).\n- Migration tags must all be unique and may only contain the characters `[a-z0-9-]`.\n  When running in a `cli_compatible` mode (see `Config::use_cli_compatible_tags`), tags must also be\n  prefixed with a timestamp, following: `[0-9]{14}_[a-z0-9-]+`.\n  See the [embedded_cli_compatible](https://github.com/jaemk/migrant_lib/blob/master/examples/embedded_cli_compatible.rs)\n  example.\n- Function migrations must have the signature `fn(ConnConfig) -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e`.\n  See the [embedded_programmable](https://github.com/jaemk/migrant_lib/blob/master/examples/embedded_programmable.rs)\n  example for a working sample of function migrations.\n- When `d-postgres` is enabled, you can specify a custom/self-signed ssl certificate using\n  `PostgresSettingsBuilder::ssl_cert_file` or setting `ssl_cert_file = \"...\"` in your `Migrant.toml`.\n\n\n```rust\nfn up(_: migrant_lib::ConnConfig) -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    print!(\" Up!\");\n    Ok(())\n}\n\nfn down(_: migrant_lib::ConnConfig) -\u003e Result\u003c(), Box\u003cdyn std::error::Error\u003e\u003e {\n    print!(\" Down!\");\n    Ok(())\n}\n\nconfig.use_migrations(\u0026[\n    migrant_lib::FileMigration::with_tag(\"create-users-table\")\n        .up(\"migrations/embedded/create_users_table/up.sql\")?\n        .down(\"migrations/embedded/create_users_table/down.sql\")?\n        .boxed(),\n    migrant_lib::EmbeddedMigration::with_tag(\"create-places-table\")\n        .up(include_str!(\"../migrations/embedded/create_places_table/up.sql\"))\n        .down(include_str!(\"../migrations/embedded/create_places_table/down.sql\"))\n        .boxed(),\n    migrant_lib::FnMigration::with_tag(\"custom\")\n        .up(up)\n        .down(down)\n        .boxed(),\n])?;\n```\n\n\n## CLI Compatibility\n\nMigration management identical to the [`migrant`](https://github.com/jaemk/migrant) CLI tool can also be embedded.\nThis method only supports file-based migrations (so `FileMigration`s or `EmbeddedMigration`s using `include_str!`)\nand those migration files names must be timestamped with the format `[0-9]{14}_[a-z0-9-]+`,\nProperly named files can be generated by `migrant_lib::new` or the `migrant` CLI tool.\nThis is required because migration order is implied by file names which must follow\na specific format and contain a valid timestamp.\n\nSee the [migrant_cli_compatible](https://github.com/jaemk/migrant_lib/blob/master/examples/migrant_cli_compatible.rs)\nexample for a working sample where migration files and a `Migrant.toml` config file are available at runtime.\n\nSee the [embedded_cli_compatible](https://github.com/jaemk/migrant_lib/blob/master/examples/embedded_cli_compatible.rs)\nexample for a working sample where the `migrant` CLI tool can be used during development, and database configuration\nand migration file contents are embedded in the application.\n\n\n## Development\n\nSee [CONTRIBUTING](https://github.com/jaemk/migrant_lib/blob/master/CONTRIBUTING.md)\n\n----\n\n\nLicense: MIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaemk%2Fmigrant_lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaemk%2Fmigrant_lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaemk%2Fmigrant_lib/lists"}