Giter Site home page Giter Site logo

synnotech-ag / synnotech.migrations Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 0.0 396 KB

A lightweight generic migration engine for .NET

License: MIT License

C# 99.64% Batchfile 0.05% TSQL 0.31%
data-access migrations generic-migration-engine relational-databases orms database database-migrations raven-db linq2db

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.