Inheritance: IMigrationMetadata
Esempio n. 1
0
        /// <summary>
        /// Alters the database schema by applying the specified migration. Versioning is unaffected by this operation and any timestamp information on the <paramref name="migration"/> is disregarded.
        /// </summary>
        public void Alter(IMigration migration)
        {
            if (migration is IReversibleMigration)
            {
                Log.Info(LogCategory.General, "Migrations used to modify the database schema directly cannot be reversed.");
            }

            var migrationMetadata = new MigrationMetadata(0, "Bypass", "This migration is being executed without affecting the versioning.");
            var stepMetadata = new MigrationStepMetadata(MigrationDirection.Up, false, new[] { migrationMetadata });
            var batch = new MigrationBatch(new[]
            {
                new MigrationStep(migration, stepMetadata)
            }, Enumerable.Empty<IMigrationMetadata>(), new NoVersioning(), Configuration);
            batch.Execute();
        }
Esempio n. 2
0
 public void ImportAll(out IReadOnlyCollection<ImportedMigration> migrations, out IReadOnlyCollection<ImportedAggregateMigration> aggregateMigrations)
 {
     Log.Info("Importing migrations...");
     DateTime start = DateTime.Now;
     var container = new CompositionContainer(_catalog);
     IEnumerable<Lazy<IMigration, IMigrationExportMetadata>> migrationExports = container.GetExports<IMigration, IMigrationExportMetadata>();
     IEnumerable<Lazy<IMigration, IAggregateMigrationExportMetadata>> aggregateMigrationExports = container.GetExports<IMigration, IAggregateMigrationExportMetadata>(AggregateMigrationExportAttribute.ContractName);
     migrations = migrationExports
         .Select(l =>
         {
             var timestamp = ExtractTimestamp(l.Metadata.ModuleName, l.Value);
             var migrationMetadata = new MigrationMetadata(timestamp, l.Metadata.ModuleName, l.Metadata.Tag);
             return new ImportedMigration(l.Value, migrationMetadata, l.Metadata.UseModuleNameAsDefaultSchema);
         }).ToList();
     aggregateMigrations = aggregateMigrationExports
         .Select(l =>
         {
             var timestamp = ExtractTimestamp(l.Metadata.ModuleName, l.Value);
             var aggregateMigrationMetadata = new AggregateMigrationMetadata(timestamp, l.Metadata.ModuleName);
             return new ImportedAggregateMigration(l.Value, aggregateMigrationMetadata);
         }).ToList();
     Log.Verbose(LogCategory.Performance, "Importing migrations took {0}s", (DateTime.Now - start).TotalSeconds);
     Log.Info("Found {0} migration(s) and {1} aggregate migration(s)", migrations.Count, aggregateMigrations.Count);
 }
Esempio n. 3
0
 internal void LoadEntry(long timestamp, string moduleName, string tag)
 {
     var entry = new MigrationMetadata(timestamp, moduleName, tag);
     _actualEntries.Add(entry);
 }
Esempio n. 4
0
 internal void LoadEntry(long timestamp, string moduleName, string tag, string migrationName, DateTime? appliedDate)
 {
     var entry = new MigrationMetadata(timestamp, moduleName, tag, migrationName, appliedDate);
     _actualEntries.Add(entry);
 }