Beispiel #1
0
 public IReadOnlyList <DeployedMigration> SetBaseline(IEnumerable <Migration> baselineMigrations)
 {
     CreateJournal();
     foreach (var migration in baselineMigrations)
     {
         var deployedMigration = new DeployedMigration(migration.MigrationNumber, migration.Name, migration.Fingerprint, true);
         _migrations.Add(migration.Name, deployedMigration);
     }
     return(_migrations.Values.OrderBy(m => m.MigrationNumber).ToList());
 }
Beispiel #2
0
        public void RecordStartMigration(Migration migrationToRun)
        {
            // either update the migration whose name matches, or append it
            var newMigration = new DeployedMigration(migrationToRun.MigrationNumber, migrationToRun.Name, migrationToRun.Fingerprint, false);

            if (_migrations.ContainsKey(newMigration.Name))
            {
                _migrations[newMigration.Name] = newMigration;
            }
            else
            {
                _migrations.Add(newMigration.Name, newMigration);
            }
        }
        /// <summary>
        /// Returns the sequenced list of offline and online migrations that have been recorded in the journal
        /// </summary>
        public IReadOnlyList <DeployedMigration> GetDeployedMigrations()
        {
            var toReturn = new List <DeployedMigration>();

            _selectCommand.Parameters["@Repeatable"].Value = false;
            using (var rdr = _selectCommand.ExecuteReader())
            {
                while (rdr.Read())
                {
                    var migrationNumber = rdr.GetInt32(0);
                    var name            = rdr.GetString(1);
                    var complete        = rdr.GetBoolean(2);
                    var fingerprint     = rdr.GetString(3);
                    var deployedScript  = new DeployedMigration(migrationNumber, name, fingerprint, complete);
                    toReturn.Add(deployedScript);
                }
            }
            return(toReturn);
        }