Evolve Database Migration Tool

repository·master·Indexed 20 days ago

https://github.com/lecaillon/evolve

A cross-platform database migration tool that uses plain SQL scripts to automate schema changes. Evolve supports SQL Server, PostgreSQL, MySQL, MariaDB, SQLite, Cassandra, and CockroachDB. It is available as a .NET library, a .NET global tool, and a standalone CLI, making it suitable for CI/CD workflows. The CLI provides commands to migrate, erase, repair, validate, and view info regarding database schema evolutions.

Tokens
1.2K
Snippets
1
Records
5
Agent score
25%

What's inside Evolve

  1. What is Evolve?

    master
    Evolve is a cross-platform database migration tool inspired by Flyway. It uses plain SQL scripts to automate database changes, helping keep schemas synchronized across different environments and development teams. It is designed for simplicity and is suitable for continuous integration and delivery (CI/CD) pipelines.
  2. Install Evolve

    master

    Evolve can be integrated into your workflow in three different ways depending on your needs:

    1. .NET Library: Use the Evolve NuGet package to embed migrations directly into your .NET applications.
    2. .NET Tool: Use the Evolve.Tool NuGet package to run Evolve as a .NET global tool.
    3. Standalone CLI: Download the pre-compiled CLI from the GitHub Releases page for use in any environment.
  3. Use the Evolve CLI to manage database migrations

    master

    The Evolve CLI allows you to manage database schema evolutions using various commands. The basic syntax requires a command, a database type, and a connection string.

    Available Commands:

    • migrate: Apply pending migrations.
    • erase: Erase the database schemas (use with caution).
    • repair: Repair the migration state.
    • info: Show information about the current state.
    • validate: Validate the migration scripts.

    Supported Databases:

    • postgresql
    • sqlite
    • sqlserver
    • mysql
    • mariadb
    • cassandra
    • cockroachdb

    Basic Usage Example:

    evolve migrate postgresql --connection-string "Host=myhost;Database=mydb;Username=user;Password=pass" --location ./migrations
    evolve migrate postgresql --connection-string "Host=myhost;Database=mydb;Username=user;Password=pass" --location ./migrations
  4. Reference: Evolve CLI Arguments and Options

    master

    The following table lists the arguments and options available to the Evolve CLI. Note that some options are specific to certain database engines (e.g., Cassandra or SQL Server).

    Arguments

    ArgumentDescriptionRequiredAllowed Values
    CommandThe action to performYesmigrate, erase, repair, info, validate
    DatabaseThe target database engineYespostgresql, sqlite, sqlserver, mysql, mariadb, cassandra, cockroachdb

    Global Options

    OptionDescriptionDefault
    -c, --connection-stringConnection string to the target database engine.(Required)
    -l, --locationPaths to scan recursively for migration scripts.Sql_Scripts
    -s, --schemaA list of schemas managed by Evolve.(Connection default)
    --metadata-table-schemaThe schema in which the metadata table is/should be.(First schema or connection default)
    --metadata-tableThe name of the metadata table.changelog
    -p, --placeholderPlaceholders for replacement in scripts (format: key:value).None
    --placeholder-prefixPrefix of the placeholders.${
    --placeholder-suffixSuffix of the placeholders.}
    --target-versionTarget version to reach.None
    --start-versionVersion used as starting point for existing databases.0
    --scripts-prefixMigration scripts file names prefix.V
    --repeatable-scripts-prefixRepeatable migration scripts file names prefix.R
    --scripts-suffixMigration scripts files extension..sql
    --scripts-separatorMigration scripts file names separator.__
    --encodingEncoding of migration scripts.UTF-8
    --command-timeoutWait time in seconds before terminating a migration attempt.30
    --ambient-tx-timeoutWait time in seconds before terminating an ambient transaction.60
    --out-of-orderAllows migration scripts to be run “out of order”.false
    --erase-disabledEnsures Evolve will never erase schemas (recommended for production).false
    --erase-on-validation-errorErases database and re-executes from scratch if validation fails (dev only).false
    --enable-cluster-modeUses a session level lock to coordinate migrations on multiple nodes.true
    -a, --embedded-resource-assemblyAssemblies to scan for embedded migration scripts.None
    -f, --embedded-resource-filterExclude embedded scripts that do not start with these filters.None
    --retry-repeatableExecute repeatable migrations repeatedly until no errors occur.false
    --transaction-modeScope of the Evolve transaction.CommitEach, CommitAll, RollbackAll
    --skip-next-migrationsMark all subsequent migrations as applied.false

    Database Specific Options

    Cassandra:

    • --keyspace: List of keyspaces managed by Evolve.
    • --metadata-table-keyspace: The keyspace for the metadata table.

    SQL Server:

    • --sql-server-access-token: An Azure-issued access token for connection.