Exemplo n.º 1
0
 public override void Down()
 {
     try
     {
         _sh.DropTable <NovicellMapBuilderMapsModel>();
         _sh.DropTable <NovicellMapBuilderDataModel>();
     }
     catch (Exception e)
     {
         _logger.Error <MapBuilderMigration>("Error dropping tables for NcMapBuilder", e);
     }
 }
Exemplo n.º 2
0
 private void DropTables()
 {
     if (_schemaHelper.TableExist(accountsTableName))
     {
         Logger.Info <CreateInitialTables>("Deleting Accounts Table");
         _schemaHelper.DropTable(accountsTableName);
     }
     if (_schemaHelper.TableExist(accountSettingsTableName))
     {
         Logger.Info <CreateInitialTables>("Deleting AccountSettings Table");
         _schemaHelper.DropTable(accountSettingsTableName);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Drops all Umbraco tables in the db
        /// </summary>
        internal void UninstallDatabaseSchema()
        {
            _logger.Info <DatabaseSchemaCreation>("Start UninstallDatabaseSchema");

            foreach (var item in OrderedTables.OrderByDescending(x => x.Key))
            {
                var tableNameAttribute = item.Value.FirstAttribute <TableNameAttribute>();

                string tableName = tableNameAttribute == null ? item.Value.Name : tableNameAttribute.Value;

                _logger.Info <DatabaseSchemaCreation>("Uninstall" + tableName);

                try
                {
                    if (_schemaHelper.TableExist(tableName))
                    {
                        _schemaHelper.DropTable(tableName);
                    }
                }
                catch (Exception ex)
                {
                    //swallow this for now, not sure how best to handle this with diff databases... though this is internal
                    // and only used for unit tests. If this fails its because the table doesn't exist... generally!
                    _logger.Error <DatabaseSchemaCreation>("Could not drop table " + tableName, ex);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Drops all Merchello tables in the database
        /// </summary>
        internal void UninstallDatabaseSchema()
        {
            _logger.Info <DatabaseSchemaCreation>("Start UninstallDatabaseSchema");

            foreach (var item in OrderedTables.OrderByDescending(x => x.Key))
            {
                var tableNameAttribute = item.Value.FirstAttribute <TableNameAttribute>();

                string tableName = tableNameAttribute == null ? item.Value.Name : tableNameAttribute.Value;

                _logger.Info <DatabaseSchemaCreation>("Uninstall" + tableName);

                try
                {
                    if (_umbSchemaHelper.TableExist(tableName))
                    {
                        _umbSchemaHelper.DropTable(tableName);
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error <DatabaseSchemaCreation>("Could not drop table " + tableName, ex);
                }
            }
        }
Exemplo n.º 5
0
 private void DeleteTables()
 {
     if (_dbSchemaHelper.TableExist("OrderedMeals"))
     {
         _dbSchemaHelper.DropTable <OrderedMealPoco>();
     }
     if (_dbSchemaHelper.TableExist("Orders"))
     {
         _dbSchemaHelper.DropTable <OrderPoco>();
     }
     if (_dbSchemaHelper.TableExist("Restaurants"))
     {
         _dbSchemaHelper.DropTable <RestaurantPoco>();
     }
     if (_dbSchemaHelper.TableExist("Statuses"))
     {
         _dbSchemaHelper.DropTable <StatusPoco>();
     }
 }
Exemplo n.º 6
0
        private void CheckFieldsDatabase()
        {
            var logger    = LoggerResolver.Current.Logger;
            var dbContext = ApplicationContext.Current.DatabaseContext;
            var dbHelper  = new DatabaseSchemaHelper(dbContext.Database, logger, dbContext.SqlSyntax);

            if (dbHelper.TableExist(PackageConstants.DbStateTable))
            {
                dbHelper.DropTable(PackageConstants.DbStateTable);
                dbHelper.CreateTable(false, typeof(TState));
            }

            var tables = new Dictionary <string, Type>
            {
                { PackageConstants.DbStatisticTable, typeof(TImageStatistic) },
            };

            for (var i = 0; i < tables.Count; i++)
            {
                if (dbHelper.TableExist(tables.ElementAt(i).Key))
                {
                    var checkColumn    = new Sql(@"SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE 
                                                TABLE_NAME = 'TinifierImagesStatistic' AND COLUMN_NAME = 'TotalSavedBytes'");
                    var checkHidePanel = new Sql(@"SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE
                                                TABLE_NAME = 'TinifierUserSettings' AND COLUMN_NAME = 'HideLeftPanel'");
                    var checkMetaData  = new Sql(@"SELECT 1 FROM INFORMATION_SCHEMA.COLUMNS WHERE 
                                                TABLE_NAME = 'TinifierUserSettings' AND COLUMN_NAME = 'PreserveMetadata'");
                    int?exists         = ApplicationContext.Current.DatabaseContext.Database.ExecuteScalar <int?>(checkColumn);
                    int?hidePanel      = ApplicationContext.Current.DatabaseContext.Database.ExecuteScalar <int?>(checkHidePanel);
                    int?metaData       = ApplicationContext.Current.DatabaseContext.Database.ExecuteScalar <int?>(checkMetaData);

                    if (exists == null || exists == -1)
                    {
                        ApplicationContext.Current.DatabaseContext.Database.Execute
                            (new Sql("ALTER TABLE TinifierImagesStatistic ADD COLUMN TotalSavedBytes bigint"));
                    }

                    if (hidePanel == null || hidePanel == -1)
                    {
                        ApplicationContext.Current.DatabaseContext.Database.Execute
                            (new Sql("ALTER TABLE TinifierUserSettings ADD COLUMN HideLeftPanel bit not null default(0)"));
                    }

                    if (metaData == null || metaData == -1)
                    {
                        ApplicationContext.Current.DatabaseContext.Database.Execute
                            (new Sql("ALTER TABLE TinifierUserSettings ADD COLUMN PreserveMetadata bit not null default(0)"));
                    }
                }
            }
        }
        public bool Undo(string packageName, XmlNode xmlData)
        {
            try
            {
                ApplicationContext   appContext           = ContextHelpers.EnsureApplicationContext();
                DatabaseSchemaHelper databaseSchemaHelper = new DatabaseSchemaHelper(appContext.DatabaseContext.Database, ContextHelpers.EnsureApplicationContext().ProfilingLogger.Logger, appContext.DatabaseContext.SqlSyntax);

                databaseSchemaHelper.DropTable <UserStartNodes>();

                return(true);
            }
            catch (Exception ex)
            {
                var message = string.Concat("Error at undo ", this.Alias(), " package action: ", ex);
                LogHelper.Error(typeof(CreateDatabase), message, ex);
            }

            return(false);
        }
Exemplo n.º 8
0
        private void DeleteTinifierTables()
        {
            var logger    = LoggerResolver.Current.Logger;
            var dbContext = ApplicationContext.Current.DatabaseContext;
            var dbHelper  = new DatabaseSchemaHelper(dbContext.Database, logger, dbContext.SqlSyntax);

            var tables = new Dictionary <string, Type>
            {
                { PackageConstants.DbSettingsTable, typeof(TSetting) },
                { PackageConstants.DbHistoryTable, typeof(TinyPNGResponseHistory) },
                { PackageConstants.DbStatisticTable, typeof(TImageStatistic) },
                { PackageConstants.DbStateTable, typeof(TState) },
                { PackageConstants.MediaHistoryTable, typeof(TinifierMediaHistory) }
            };

            for (var i = 0; i < tables.Count; i++)
            {
                if (dbHelper.TableExist(tables.ElementAt(i).Key))
                {
                    dbHelper.DropTable(tables.ElementAt(i).Key);
                }
            }
        }
Exemplo n.º 9
0
 public override void Down()
 {
     _schemaHelper.DropTable <Dto.Ancestor.Ancestor100>();
     _schemaHelper.DropTable <Dto.Entry.Entry100>();
 }