Migrondi

A Super simple SQL Migrations Tool for SQLite, PostgreSQL, MySQL and SQL Server

MIT License

Stars
80

Bot releases are hidden (Show)

Migrondi - v1.0.0-beta-010 Latest Release

Published by AngelMunoz 8 months ago

  • Allow manual handling of transactions
  • update dependencies
  • if a rollback is empty, stop there.
    • known issue: if the rollback is made of comments it will still try to run

Full Changelog: https://github.com/AngelMunoz/Migrondi/compare/v1.0.0-beta-009...v1.0.0-beta-010

Migrondi - v1.0.0-beta-009

Published by AngelMunoz 8 months ago

This release adds the Microsoft.Extensions.Logging package to hide some details of the creation of an IMigrondi instance when using the library code.

Breaking Changes

Change the signature of MigrondiFactory to avoid asking extra information and orchestration from users.

previously

let factory = Migrondi.MigrondiFactory(logger)

let config = MigrondiConfig.Default

let rootDir =
  Uri(__SOURCE_DIRECTORY__ + $"{Path.DirectorySeparatorChar}", UriKind.Absolute)

let migrationsDir =
  Uri(Config.ensureWellFormed config.migrations, UriKind.Relative)

let migrondi = factory.Invoke(config, rootDir, migrationsDir)

Now:


let config = MigrondiConfig.Default

let migrondi = Migrondi.MigrondiFactory(config, ".")

On the follwing releases that MigrondiFactory name may be changed to simply Create

Full Changelog: https://github.com/AngelMunoz/Migrondi/compare/v1.0.0-beta-008...v1.0.0-beta-009

Migrondi - v1.0.0-beta-008

Published by AngelMunoz 8 months ago

Woops... I also missed a method on the public API on the last release, here's the good one!

As I was saying before:
This Version adds a small convenience API that was missing on the IMigrondi interface
Now it should be very simple to create and run migrations programmatically, here's an example how you can create and run migrations from an F# script!

#r "nuget: Migrondi.Core, 1.0.0-beta-008"
#r "nuget: Microsoft.Extensions.Logging"
#r "nuget: Microsoft.Extensions.Logging.Console"

open System
open System.IO
open Migrondi.Core

open Microsoft.Extensions.Logging

module Config =
  let getLogger loggerName =
    let loggerFactory =
      LoggerFactory.Create(fun builder ->
        builder.SetMinimumLevel(LogLevel.Debug).AddSimpleConsole() |> ignore
      )

    loggerFactory.CreateLogger loggerName

  let ensureWellFormed (migrationsDir: string) =
    // when you're using URIs "./path" is not the same as "./path/"
    // the first one is a file and the second one is a directory
    // so ensure you always end your paths with a directory separator

    if Path.EndsInDirectorySeparator(migrationsDir) then
      migrationsDir
    else
      $"{migrationsDir}{Path.DirectorySeparatorChar}"


let logger = Config.getLogger("sample-app")
let factory = Migrondi.MigrondiFactory(logger)

let config = MigrondiConfig.Default

let rootDir =
  Uri(__SOURCE_DIRECTORY__ + $"{Path.DirectorySeparatorChar}", UriKind.Absolute)

let migrationsDir =
  Uri(Config.ensureWellFormed config.migrations, UriKind.Relative)

let migrondi = factory.Invoke(config, rootDir, migrationsDir)


// Let's create a new Migration, since this is just an I/O operation
// there's no need to initialize the database yet, but ideally
// you would want to do that anyways for safety
migrondi.RunNew(
  "add-test-table",
  "create table if not exists test (id int not null primary key);",
  "drop table if exists test;"
)

// Before we can talk to the database we need to initialize the migrondi object
// this will ensure that the migrations directory exists, and the required pieces
// of information are available in the database to see if it is ready to accept migrations.
migrondi.Initialize()

// once that the migrondi service is initialized we can try to commmunicate to the
// database and in this case go for a dry run
let applied = migrondi.DryRunUp()

logger.LogInformation(
  $"List of the migrations that would have been ran:\n\n%A{applied}"
)

Full Changelog: https://github.com/AngelMunoz/Migrondi/compare/v1.0.0-beta-006...v1.0.0-beta-008

Migrondi - v1.0.0-beta-007

Published by AngelMunoz 8 months ago

This Version adds a small convenience API that was missing on the IMigrondi interface
Now it should be very simple to create and run migrations programmatically, here's an example how you can create and run migrations from an F# script!

Please ignore this release and check the notes on v1.0.0-beta-008

Full Changelog: https://github.com/AngelMunoz/Migrondi/compare/v1.0.0-beta-006...v1.0.0-beta-007

Migrondi - v1.0.0-beta-006

Published by AngelMunoz about 1 year ago

This release doesn't add up much, I'm drive testing the library portion of this project in https://github.com/AngelMunoz/MigrondiUI so once I get in better shape for that project, I'll start tweaking parts of the API before moving to RC stage.

Add missing helpers for the MigrondiDriver type as well as removing an extra namespace in the Migrondi file.

Full Changelog: https://github.com/AngelMunoz/Migrondi/compare/v1.0.0-beta-005...v1.0.0-beta-006

Migrondi - v1.0.0-beta-005

Published by AngelMunoz about 1 year ago

This release is to switch out some Public API names and switch the factory functions to classes

I'm dogfooding this project from a C# application and found a few issues and weirdness from using the library side that I'm trying to address with these changes.

And also added a simpler way to initialize the migrondi service (in case you don't care about the internal services of migrondi

F# Code

let migrondiFactory = Migrondi.MigrondiFactory(logger)
let migrondi: IMigrondi = migrondiFactory.Invoke(config, projectRoot, migrationsDir)
migrondi.DryRunUp()

C# code

var migrondiFactory = Migrondi.MigrondiFactory(logger);

IMigrondi migrondi = migrondiFactory(sconfig, rootProject, migrationsDir);
migrondi.DryRunUp();

Full Changelog: https://github.com/AngelMunoz/Migrondi/compare/v1.0.0-beta-004...v1.0.0-beta-005

Migrondi - v1.0.0-beta-004

Published by AngelMunoz about 1 year ago

Changes in this version

  • Serialization API
    • Split into Configuration Serializer and Migration Serializer - this was made in order to make it easier to construct the services and replace them individually where needed vs the previous API that required a nested set of interfaces to get to the correct API
  • Migrate from the internal async implementation to IcedTasks - Iced tasks keeps the benefit of using a performant Task-based API keeping the benefits of the async model from F# so there's less Async <-> Task conversion interop
  • Implement the missing bits of the Migrondi Service's Async API so you can start coding against it!
     
    Also, docs are starting to get in shape I think there's less things to worry about now and if I don't get any crazy ideas we might get an RC version soon.

Full Changelog: https://github.com/AngelMunoz/Migrondi/compare/v1.0.0-beta-003...v1.0.0-beta-004

Migrondi - Updates to Public API

Published by AngelMunoz about 1 year ago

In the last preview for some reason I forgot to add and update the signature files to properly limit the public API of the Core project

This should be fixed now and should reflect the current desired public API offering

Full Changelog: https://github.com/AngelMunoz/Migrondi/compare/v1.0.0-beta-001..v1.0.0-beta-003

Migrondi - Update Public API

Published by AngelMunoz about 1 year ago

Renamed a few APIs to to make naming consistent

Full Changelog: https://github.com/AngelMunoz/Migrondi/compare/v1.0.0-beta-001...v1.0.0-beta-002

Migrondi - First v1 Preview

Published by AngelMunoz about 1 year ago

Hey there, It's been quite a while!

Today I have come to announce the first v1 beta for migrondi!

Given that I'm very clear what this tool is aiming for, and that the existing functionality has been like it for a complete while I decided to re-architect most of the core code base to enable a bunch of cool stuff for the future, especially around using this as a library in your own projects so you can have better control over how everything is executed!

This means that technically it is a breaking change from older releases specially around the CLI, but I made this tool specifically to be compatible with v0 script format, so it should be a drop-in replacement in that sense.
the CLI is a little bit easier to use with less typing for obvious choices like the number of migrations you want to run up/down.

So, this time I'm releasing two artifacts:

  • Migrondi (the tool we already know)
  • Migrondi.Core (The library that powers the CLI but now at your disposal!)

Oh by the way, the core library should be C#/VB compatible (e.g. no F# specific types) :) so feel free to try it out specially from the C#/VB side!

I will eventually update the existing vscode tool and related projects, but in the meantime this should be ready to try!

Full Changelog: https://github.com/AngelMunoz/Migrondi/compare/v0.7.1...v1.0.0-beta-001

Migrondi - Fix up/down commands for postgresql

Published by AngelMunoz almost 3 years ago

What's Changed

  • A fix for #31
Migrondi - v0.7.0 Next milestone

Published by AngelMunoz about 3 years ago

Migrondi 0.7.0 had really big changes in it's architecture which will allow you in future version to use it as a library

Highlights

We're targeting .NET 6 now!

  • New Command! migrondi status -n SampleMigration_1628565399809.sql

    This command will let you know if a particular file is present in the database while it might not be very useful for cli users, this will allow the migrondi-vscode extension to report status by file inside vscode!

  • Improved output logs with more colors (thanks to Spectre.Console)

  • Added the following general flags

    • -j, --json ~ produces each line of the log as a json object (helpful if you're cosuming the stdout when invoked from other tools)
    • -nc, --no-color ~ if you are using migrondi in a CI/CD environment you might not need colors, so this will disable Spectre.Console coloring output

Breaking changes

While most of the public API for the CLI has been left untouched, we changed from CommandLineParser.FSharp to Argu which gives us a little bit more of flexibility, but we might have broken some things inadvertently I tried all of the commands personally but let me know if something slipped by

  • The --all flag has been removed, if you need every migration use -1 or 0 to get everything.
  • The up and down still run everything by default, but they do it as a dry-run by default to prevent accidental migrations, use --dry-run false to ensure you want to run your migrations against your database.

Here's the new --help menu:

USAGE: Migrondi.exe [--help] [--no-color [<bool>]] [--json [<bool>]] [<subcommand> [<options>]]

SUBCOMMANDS:

    init <options>        Creates basic files and directories to start using migrondi.
    new <options>         Creates a new Migration file.
    up <options>          Runs the migrations against the database.
    down <options>        Rolls back migrations from the database.
    list <options>        List the amount of migrations in the database.
    status <options>      Checks if a migration file is present in the database, this file has to be inside
                          "migrationsDir" from migrondi.json

    Use 'Migrondi.exe <subcommand> --help' for additional information.

OPTIONS:

    --no-color, -nc [<bool>]
                          Write to the console without coloring enabled.
    --json, -j [<bool>]   Output to the console with a json format.
    --help                display this list of options.

If you were using the list command inside a script, you will need to update it's usage

USAGE: Migrondi.exe list [--help] [--amount [<int>]] [--kind [<present|pending|both>]]

OPTIONS:

    --amount, -n [<int>]  Amount of migrations to get, defaults to 5.
    --kind, -k [<present|pending|both>]
                          Which migrations should be listed, defaults to "pending".
    --help                display this list of options.

All of the above are related to #20 #21 #22

Migrondi - Bump Deps

Published by AngelMunoz about 3 years ago

This release bumps dependencies and provides a macOS binary this will be the last release targeting netcoreapp3.1 (unless bugs are reported), once .NET6 is out it will be updated accordingly

Migrondi - Dry Run

Published by AngelMunoz almost 4 years ago

This release includes a new option for the up and down commands!
you can now type

  • migrondi up --dry-run true
  • migrondi up -d true
  • migrondi down --dry-run true
  • migrondi down -d true

This will print out to the console what is exactly going to run against your database

Migrondi - Allow Complex Filenames

Published by AngelMunoz almost 4 years ago

Thanks to @VitorRigoni now you should be able to use more flexible names for your migrations

examples

  • my_migration_is_nice_1608393986966.sql
  • my-migration_is_nicer-48984_123_1608393986966.sql
  • 123123__asasd_123123---___#_1608393986966.sql

not that you should use names like the last one but you can have more than 1 underscore in your migrations

Migrondi - Exit correctly on up command failure

Published by AngelMunoz almost 4 years ago

This release includes a fix to the exit code applied when the application had exceptions, not every case was covered by exit(1)
Thanks to @VitorRigoni to point this out and send a PR

Migrondi - init fix

Published by AngelMunoz about 4 years ago

fixes an issue when creating the init configuration the migrationsDir property was "/' instead of "migrations/"

for .net users you can now install via nuget global tool
dotnet tool install --global Migrondi --version 0.4.1

Migrondi - Init command

Published by AngelMunoz over 4 years ago

Adds a init command useful when you are starting from scratch that gets you ready to start working

Add nupkg to install it as a dotnet tool

Migrondi - Rename to Migrondi

Published by AngelMunoz over 4 years ago

Basically this is just a "rename" of the project I found out some products names as "Sqlator" and I don't want to deal with that
I decided to put the binaries inside a zip folder, just uncompress and put it in your path to start working with it

Migrondi - Multiple Databases!

Published by AngelMunoz over 4 years ago

Removed Dapper and the F# wrapper in favor of RepoDb.

This allows basic support for SQL Server, MySQL, SQLite, PostgreSQL
I have manually tested in MySQL, SQLite as well as PostgreSQL

If you find a bug or missing a feature, please let me know