private static void SetExecuted(List <MigrationInfo> migrations)
        {
            MigrationLogic.EnsureMigrationTable <SqlMigrationEntity>();

            var first = migrations.FirstOrDefault();

            var executedMigrations = Database.Query <SqlMigrationEntity>().Select(m => new { m.VersionNumber, m.Comment })
                                     .OrderBy(a => a.VersionNumber)
                                     .ToList()
                                     .Where(d => first == null || first.Version.CompareTo(d.VersionNumber) <= 0)
                                     .ToList();

            var dic = migrations.ToDictionaryEx(a => a.Version, "Migrations in folder");

            foreach (var migration in executedMigrations)
            {
                var m = dic.TryGetC(migration.VersionNumber !);
                if (m != null)
                {
                    m.IsExecuted = true;
                }
                else
                {
                    migrations.Add(new MigrationInfo
                    {
                        FileName   = null,
                        Comment    = ">> In Database Only << " + migration.Comment,
                        IsExecuted = true,
                        Version    = migration.VersionNumber !
                    });
Example #2
0
        void SetExecuted()
        {
            SafeConsole.WriteLineColor(ConsoleColor.DarkGray, "Reading C# migrations...");

            MigrationLogic.EnsureMigrationTable <CSharpMigrationEntity>();

            var database = Database.Query <CSharpMigrationEntity>().Select(m => m.UniqueName).OrderBy().ToHashSet();

            foreach (var v in this.Migrations)
            {
                v.IsExecuted = database.Contains(v.UniqueName);
            }
        }