Пример #1
0
        public void FlagMigrationAsFinished(IUmbracoMigration migration)
        {
            var migrationName = migration.GetType().Name;

            var migrationHistory = UmbracoDatabase.Single <MigrationHistory>("WHERE Name = @Name", new { Name = migrationName });

            migrationHistory.Completed = true;
            UmbracoDatabase.Update(migrationHistory);
        }
Пример #2
0
        private void ProcessMigration(IUmbracoMigration umbracoMigration)
        {
            if (_databaseUtil.HasMigrationExecuted(umbracoMigration))
            {
                return;
            }

            _databaseUtil.FlagMigrationAsStarted(umbracoMigration);

            _databaseUtil.UmbracoDatabase.OpenSharedConnection();

            try
            {
                _databaseUtil.UmbracoDatabase.BeginTransaction();

                Log.Info(string.Format("========== Executing migration {0} ==========",
                                       umbracoMigration.GetType().FullName));

                umbracoMigration.Migrate();

                Log.Info(string.Format("---------- Executed migration {0} ----------",
                                       umbracoMigration.GetType().FullName));

                _databaseUtil.FlagMigrationAsFinished(umbracoMigration);

                Log.Info("Transaction completed");
                _databaseUtil.UmbracoDatabase.CompleteTransaction();
            }
            catch (Exception exception)
            {
                Log.Error("Transaction aborted.", exception);
                _databaseUtil.UmbracoDatabase.AbortTransaction();
                throw;
            }
            finally
            {
                Log.Info("Shared connection closed.");
                _databaseUtil.UmbracoDatabase.CloseSharedConnection();
            }
        }
Пример #3
0
        public bool HasMigrationExecuted(IUmbracoMigration migration)
        {
            var migrationName = migration.GetType().Name;

            try
            {
                UmbracoDatabase.OpenSharedConnection();

                using (var transaction = GetTransaction())
                {
                    var migrationHistory     = UmbracoDatabase.FirstOrDefault <MigrationHistory>("WHERE Name = @Name", new { Name = migrationName });
                    var hasMigrationExecuted = migrationHistory != null;

                    Log.Debug(string.Format("HasMigrationExecuted for {0} is {1}", migrationName, hasMigrationExecuted));

                    transaction.Complete();
                    return(hasMigrationExecuted);
                }
            }
            finally
            {
                UmbracoDatabase.CloseSharedConnection();
            }
        }
Пример #4
0
        public void FlagMigrationAsStarted(IUmbracoMigration migration)
        {
            try
            {
                UmbracoDatabase.OpenSharedConnection();

                using (var transaction = GetTransaction())
                {
                    var row = new MigrationHistory
                    {
                        Completed = false,
                        Name      = migration.GetType().Name,
                        Timestamp = DateTime.UtcNow
                    };

                    UmbracoDatabase.Insert(row);
                    transaction.Complete();
                }
            }
            finally
            {
                UmbracoDatabase.CloseSharedConnection();
            }
        }
 public MigrationStartingEventArgs([NotNull] IUmbracoMigration migration, [NotNull] IMigrationContext context) : base(migration, context)
 {
 }
Пример #6
0
 public MigrationEventArgs([NotNull] IUmbracoMigration migration, [NotNull] IMigrationContext context) : base(context)
 {
     Migration = Argument.NotNull("migration", migration);
 }
Пример #7
0
 public EmbeddedResourceHelper(IUmbracoMigration migration)
 {
     _migration = migration;
 }