Exemplo n.º 1
0
        public MigrationMapStateInfo GetState(MigrationMap migrationMap)
        {
            var executedMigrations    = dataProvider.ListExecutedMigrations(identifier).Select(x => x.MigrationId);
            var migrationMapStateInfo = new MigrationMapStateInfo()
            {
                MigrationNodesInfo = migrationMap.MigrationNodes.Select(x => {
                    var nodeInfo = new MigrationNodeStateInfo()
                    {
                        MigrationNode = x
                    };
                    nodeInfo.MigrationsInfo = x.Migrations.Select(y =>
                    {
                        var migrationInfo = new MigrationStateInfo()
                        {
                            Migration = y
                        };
                        migrationInfo.CurrentState = executedMigrations.Contains(y.Identifier) ? Migration.MigrationState.Executed : Migration.MigrationState.ToUpgrade;
                        return(migrationInfo);
                    }).ToList();
                    return(nodeInfo);
                }).ToList()
            };

            return(migrationMapStateInfo);
        }
Exemplo n.º 2
0
        public MigrationMap GetMigrationMap()
        {
            var migrationMap = new MigrationMap();
            JsonFileMigrationMap jsonMap = JsonFileMigrationMap.FromJsonFile(configPath);
            
            migrationMap.MigrationNodes = new List<IMigrationNode>();
            migrationMap.Identifier = jsonMap.Identifier;

            foreach (var version in jsonMap.Versions)
            {
                var node = new MigrationNode();
                node.Identifier = version.Name;
                node.Migrations = new List<IMigration>();

                foreach (var migration in version.Migrations)
                {
                    var nMigration = new FlaggedFileMigration(basePath, migration.File, migration.Description);
                    node.Migrations.Add(nMigration);
                }
                migrationMap.MigrationNodes.Add(node);
            }

            return migrationMap;
        }