Пример #1
0
        void ExecuteMigrations(IEnumerable <IMigration> migrations)
        {
            var store       = GetStore();
            var lastApplied = store.Items <ExecutedMigration>()
                              .OrderByDescending(migration => migration.Number)
                              .Take(1)
                              .ToList()
                              .Select(migration => migration.Number)
                              .FirstOrDefault();

            log.Debug("Last migration executed according to database was " + lastApplied);

            migrations.Where(migration => migration.Number() > lastApplied)
            .ToList().ForEach(migration =>
            {
                log.Debug("Executing migration " + migration.Number());
                migration.Execute();
                var executed = new ExecutedMigration(migration);
                store.Save(executed);
            });
        }
        void ExecuteMigrations(IEnumerable<IMigration> migrations)
        {
            var store = GetStore();
            var lastApplied = store.Items<ExecutedMigration>()
                .OrderByDescending(migration => migration.Number)
                .Take(1)
                .ToList()
                .Select(migration => migration.Number)
                .FirstOrDefault();
            log.Debug("Last migration executed according to database was " + lastApplied);

            migrations.Where(migration => migration.Number() > lastApplied)
                .ToList().ForEach(migration =>
                    {
                        log.Debug("Executing migration " + migration.Number());
                        migration.Execute();
                        var executed = new ExecutedMigration(migration);
                        store.Save(executed);
                    });
        }