Code Monkey home page Code Monkey logo

synnotech.migrations's Introduction

Synnotech.Migrations

A lightweight generic migration engine for .NET

Synnotech Logo

License NuGet

When starting a new project, do you always spent too much time on how you can migrate your database? Do you want a migration mechanism that is independent of any persistence technology, like ORMs for relational databases? Worry no more because Synnotech.Migrations offers just that! Our generic migration engine is written in such a way so that you can easily adapt it to your own data access layer, no matter the technology: relational databases with and without ORMs, document or graph databases, the file system, or web services - the possibilities are endless.

Synnotech.Migrations also offers integration packages that get you started quickly:

Please visit the corresponding pages for further documentation.

Our Philosophy for Migrations

  • The dev is in control: Synnotech.Migrations is unobtrusive, it does not care about the internal structure of your migrations. We recommend choosing the best tools to manipulate your target system, e.g. TSQL for MS SQL Server, PL/SQL for Oracle, RQL or the RavenDB.Client for Raven DB, HTTP calls for a web service. Simply execute the code you want within your migrations.
  • We don't look back: Migrations should not have a Down method to reverse it. Not only does this extend the time you need to implement a migration, but it also might lead to data loss, e.g. when a column or table is dropped that was previously added. If one of your migrations is erroneous, write a new one that fixes it.
  • No addtional CLI tools: Synnotech.Migrations offers you an API that you can directly call within your apps. You don't need additional tools for the command line.

Supported Frameworks

Synnotech.Migrations is build for .NET Standard 2.0 and .NET Standard 2.1, so you can use it on all platforms that support it, e.g. like:

  • .NET 5 or newer
  • .NET Core 2.0 or newer
  • .NET Framework 4.6.1 or newer
  • Mono 4.6 or newer
  • Unity 2018.1

Contributions Are Welcome

If you have questions or have an idea for a new feature, please create an issue.

TODO: we need to create contributing guidelines

synnotech.migrations's People

Contributors

feo2x avatar tom9221 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

synnotech.migrations's Issues

Latest MigrationInfo is incorrect if all previous migrations have the same AppliedAt time stamp

Description

PR #8 solved #7 by correctly querying the most recently applied MigrationInfo in descending order:

var migrationInfos = await DataConnection.GetTable<TMigrationInfo>()
                                         .OrderByDescending(migrationInfo => migrationInfo.AppliedAt)
                                         .Take(Take)
                                         .ToListAsync(cancellationToken);
return migrationInfos.GetLatestMigrationInfo();

Unfortunately an incorrect migration is still returned in the following scenario:

  1. There are more than Take migrations (defaults to 100)
  2. All migrations are applied onto an empty database in a single run of MigrationEnginge.MigrateAsync(). All of the corresponding MigrationInfos are assigned the same time stamp
  3. During the next run of the MigrationEngine it is up to the database engine to determine the order as the AppliedAt values of all MigrationInfos are equal. In the case of MSSQL Server the first Take migrations are returned, not the last. Consequently, migration #Take is incorrectly identified as the last one and the engine tries to reapply the remaining migrations starting from Take + 1.

Possible Workarounds

  1. Use different timestamps for every pending migration. This does not solve the problem for existing databases, though.
  2. Order by the AppliedAt AND the Id column. This workaround depends on the ID generation for the MigrationInfos table.

Error when you have more than a hundred migrations

When there are more than a hundred migrations managed with text versions, the migration engine will run migrations several times because it does not correctly determine the latest migration version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.