All Projects → jaemk → migrant_lib

jaemk / migrant_lib

Licence: other
Embeddable migration management

Programming Languages

rust
11053 projects
shell
77523 projects
powershell
5483 projects

Projects that are alternatives of or similar to migrant lib

Postgres Migrations
🐦 A Stack Overflow-inspired PostgreSQL migration library with strict ordering and immutable migrations
Stars: ✭ 161 (+631.82%)
Mutual labels:  postgres, migrations, database-migrations
Goose
A database migration tool. Supports SQL migrations and Go functions.
Stars: ✭ 2,112 (+9500%)
Mutual labels:  postgres, migrations, database-migrations
Zero downtime migrations
Zero downtime migrations with ActiveRecord 3+ and PostgreSQL
Stars: ✭ 513 (+2231.82%)
Mutual labels:  postgres, migrations
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+34954.55%)
Mutual labels:  postgres, migrations
Rpg Boilerplate
Relay (React), Postgres, and Graphile (GraphQL): A Modern Frontend and API Boilerplate
Stars: ✭ 62 (+181.82%)
Mutual labels:  postgres, migrations
db-migrator.go
DB migrations. CLI and Golang
Stars: ✭ 13 (-40.91%)
Mutual labels:  migrations, database-migrations
plow
👨‍🌾 Postgres migrations and seeding made easy
Stars: ✭ 13 (-40.91%)
Mutual labels:  postgres, migrations
Node Pg Migrate
Node.js database migration management for Postgresql
Stars: ✭ 838 (+3709.09%)
Mutual labels:  postgres, migrations
Phoenix
Framework agnostic database migrations for PHP.
Stars: ✭ 81 (+268.18%)
Mutual labels:  migrations, database-migrations
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 2,315 (+10422.73%)
Mutual labels:  postgres, migrations
shyft
⬡ Shyft is a server-side framework for building powerful GraphQL APIs 🚀
Stars: ✭ 56 (+154.55%)
Mutual labels:  postgres, migrations
migrant
Migration management for PostgreSQL/SQLite/MySQL
Stars: ✭ 85 (+286.36%)
Mutual labels:  migrations, database-migrations
Dbmate
🚀 A lightweight, framework-agnostic database migration tool.
Stars: ✭ 2,228 (+10027.27%)
Mutual labels:  migrations, database-migrations
Pg chameleon
MySQL to PostgreSQL replica system
Stars: ✭ 274 (+1145.45%)
Mutual labels:  postgres, database-migrations
Lol dba
lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.
Stars: ✭ 1,363 (+6095.45%)
Mutual labels:  migrations, database-migrations
Zws
Shorten URLs using invisible spaces.
Stars: ✭ 780 (+3445.45%)
Mutual labels:  postgres, database-migrations
Phinx
PHP Database Migrations for Everyone
Stars: ✭ 4,245 (+19195.45%)
Mutual labels:  migrations, database-migrations
Migrate Mongo
A database migration tool for MongoDB in Node
Stars: ✭ 481 (+2086.36%)
Mutual labels:  migrations, database-migrations
Fizz
A Common DSL for Migrating Databases
Stars: ✭ 92 (+318.18%)
Mutual labels:  postgres, migrations
migrations
Migrations is a database migration tool that uses go's database/sql from the standard library
Stars: ✭ 17 (-22.73%)
Mutual labels:  migrations, database-migrations

migrant_lib

Build Status crates.io:migrant_lib docs

Embeddable migration management

Also see migrant CLI

migrant_lib allows defining and embedding management of database migrations and (connection) configuration in your compiled application.

Available Features:

Feature Backend
d-postgres Enable postgres connectivity
d-sqlite Enable sqlite connectivity
d-mysql Enable mysql connectivity
d-all Enable all backends

Notes:

  • No features are enabled by default
  • As of 0.20.0 the d-sqlite feature does not use rusqlites bundled feature. If you would like sqlite to be bundled with your application, you will have to include rusqlite and enable the bundled feature in your project.

Usage

  • You must enable the database features relevant to your usecase (d-postgres / d-sqlite / d-mysql).
  • Migrations can be defined as files, string literals, or functions.
  • File migrations can be either read from files at runtime or embedded in your executable at compile time (using include_str!).
  • Migration tags must all be unique and may only contain the characters [a-z0-9-]. When running in a cli_compatible mode (see Config::use_cli_compatible_tags), tags must also be prefixed with a timestamp, following: [0-9]{14}_[a-z0-9-]+. See the embedded_cli_compatible example.
  • Function migrations must have the signature fn(ConnConfig) -> Result<(), Box<dyn std::error::Error>>. See the embedded_programmable example for a working sample of function migrations.
  • When d-postgres is enabled, you can specify a custom/self-signed ssl certificate using PostgresSettingsBuilder::ssl_cert_file or setting ssl_cert_file = "..." in your Migrant.toml.
fn up(_: migrant_lib::ConnConfig) -> Result<(), Box<dyn std::error::Error>> {
    print!(" Up!");
    Ok(())
}

fn down(_: migrant_lib::ConnConfig) -> Result<(), Box<dyn std::error::Error>> {
    print!(" Down!");
    Ok(())
}

config.use_migrations(&[
    migrant_lib::FileMigration::with_tag("create-users-table")
        .up("migrations/embedded/create_users_table/up.sql")?
        .down("migrations/embedded/create_users_table/down.sql")?
        .boxed(),
    migrant_lib::EmbeddedMigration::with_tag("create-places-table")
        .up(include_str!("../migrations/embedded/create_places_table/up.sql"))
        .down(include_str!("../migrations/embedded/create_places_table/down.sql"))
        .boxed(),
    migrant_lib::FnMigration::with_tag("custom")
        .up(up)
        .down(down)
        .boxed(),
])?;

CLI Compatibility

Migration management identical to the migrant CLI tool can also be embedded. This method only supports file-based migrations (so FileMigrations or EmbeddedMigrations using include_str!) and those migration files names must be timestamped with the format [0-9]{14}_[a-z0-9-]+, Properly named files can be generated by migrant_lib::new or the migrant CLI tool. This is required because migration order is implied by file names which must follow a specific format and contain a valid timestamp.

See the migrant_cli_compatible example for a working sample where migration files and a Migrant.toml config file are available at runtime.

See the embedded_cli_compatible example for a working sample where the migrant CLI tool can be used during development, and database configuration and migration file contents are embedded in the application.

Development

See CONTRIBUTING


License: MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].