コード例 #1
0
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            var ctx = applicationContext.DatabaseContext;

            using (var db = ctx.Database)
            {
                var schema = new DatabaseSchemaHelper(db, applicationContext.ProfilingLogger.Logger, ctx.SqlSyntax);

                if (!schema.TableExist("simpleTranslationProposals"))
                {
                    schema.CreateTable <TranslationProposal>(false);
                }
                if (!schema.TableExist("simpleTranslationTasks"))
                {
                    schema.CreateTable <TranslationTask>(false);
                }
                if (!schema.TableExist("simpleTranslationUserLanguages"))
                {
                    schema.CreateTable <UserLanguage>(false);
                }
                if (!schema.TableExist("simpleTranslationUserRoles"))
                {
                    schema.CreateTable <UserRole>(false);
                }
            }
        }
コード例 #2
0
        //This happens everytime the Umbraco Application starts
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            //Get the Umbraco Database context
            var dbCtx = applicationContext.DatabaseContext;
            var db    = new DatabaseSchemaHelper(dbCtx.Database, applicationContext.ProfilingLogger.Logger, dbCtx.SqlSyntax);

            //Check if the DB table does NOT exist
            if (!db.TableExist("PetaPocoHomePageWhatsNew"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable <PetaPocoHomePageWhatsNew>(false);
            }

            if (!db.TableExist("PetaPocoOutOfDateContent"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable <PetaPocoOutOfDateContent>(false);
            }

            if (!db.TableExist("PetaPocoUserProfiles"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable <PetaPocoUserProfile>(false);
            }
        }
コード例 #3
0
        protected void EnsureTablesExist()
        {
            // TODO: Should this be stored in UmbracoIdentity SQL CE database?
            var dbCtx = ApplicationContext.Current.DatabaseContext;
            var dbSchemaHelper = new DatabaseSchemaHelper(dbCtx.Database, LoggerResolver.Current.Logger, dbCtx.SqlSyntax);

            if (!dbSchemaHelper.TableExist(typeof(OAuthClient).Name))
            {
                // Create table
                dbSchemaHelper.CreateTable(false, typeof(OAuthClient));

                // Seed the table
                dbCtx.Database.Save(new OAuthClient
                {
                    ClientId = "DemoClient",
                    Name = "Demo Client",
                    Secret = "demo",
                    SecurityLevel = SecurityLevel.Insecure,
                    RefreshTokenLifeTime = 14400,
                    AllowedOrigin = "*"
                });
            }

            if (!dbSchemaHelper.TableExist(typeof(OAuthRefreshToken).Name))
            {
                // Create table
                dbSchemaHelper.CreateTable(false, typeof(OAuthRefreshToken));
            }
        }
コード例 #4
0
ファイル: AddTaxMethodColumn.cs プロジェクト: vonbv/Merchello
 /// <summary>
 /// Adds the productTaxation field on an upgrade
 /// </summary>
 public override void Up()
 {
     if (_databaseSchemaHelper.TableExist("merchTaxMethod"))
     {
         this.Alter.Table("merchTaxMethod").AddColumn("productTaxMethod").AsBoolean().NotNullable().WithDefaultValue('0');
     }
 }
コード例 #5
0
        protected void EnsureTablesExist()
        {
            // TODO: Should this be stored in UmbracoIdentity SQL CE database?
            var dbCtx          = ApplicationContext.Current.DatabaseContext;
            var dbSchemaHelper = new DatabaseSchemaHelper(dbCtx.Database, LoggerResolver.Current.Logger, dbCtx.SqlSyntax);

            if (!dbSchemaHelper.TableExist(typeof(OAuthClient).Name))
            {
                // Create table
                dbSchemaHelper.CreateTable(false, typeof(OAuthClient));

                // Seed the table
                dbCtx.Database.Save(new OAuthClient
                {
                    ClientId             = "DemoClient",
                    Name                 = "Demo Client",
                    Secret               = "demo",
                    SecurityLevel        = SecurityLevel.Insecure,
                    RefreshTokenLifeTime = 14400,
                    AllowedOrigin        = "*"
                });
            }

            if (!dbSchemaHelper.TableExist(typeof(OAuthRefreshToken).Name))
            {
                // Create table
                dbSchemaHelper.CreateTable(false, typeof(OAuthRefreshToken));
            }
        }
コード例 #6
0
        private void SetupCustomTables(ApplicationContext applicationContext)
        {
            var logger       = LoggerResolver.Current.Logger;
            var dbContext    = applicationContext.DatabaseContext;
            var schemaHelper = new DatabaseSchemaHelper(dbContext.Database, logger, dbContext.SqlSyntax);

            if (!schemaHelper.TableExist("PolRegioUser"))
            {
                schemaHelper.CreateTable <UserDB>(overwrite: false);
            }

            if (!schemaHelper.TableExist("PolRegioUserRegion"))
            {
                schemaHelper.CreateTable <UserRegionDB>(overwrite: false);
            }

            if (!schemaHelper.TableExist("PolRegioAgreement"))
            {
                schemaHelper.CreateTable <AgreementDB>(overwrite: false);
            }

            if (!schemaHelper.TableExist("PolRegioUserAgreement"))
            {
                schemaHelper.CreateTable <UserAgreementDB>(overwrite: false);
            }

            if (!schemaHelper.TableExist("PolRegioStations"))
            {
                schemaHelper.CreateTable <StationDB>(overwrite: false);
            }
        }
コード例 #7
0
        protected override void ApplicationStarting(
            UmbracoApplicationBase umbracoApplication,
            ApplicationContext applicationContext)
        {
            DatabaseContext      ctx      = ApplicationContext.Current.DatabaseContext;
            DatabaseSchemaHelper dbSchema = new DatabaseSchemaHelper(
                ctx.Database,
                ApplicationContext.Current.ProfilingLogger.Logger,
                ctx.SqlSyntax);

            if (!dbSchema.TableExist <Category>())
            {
                dbSchema.CreateTable <Category>(false);
                ctx.Database.Execute("ALTER TABLE Categories ADD CONSTRAINT UC_CategoryName UNIQUE(CategoryName);");
            }
            if (!dbSchema.TableExist <Product>())
            {
                dbSchema.CreateTable <Product>(false);
                ctx.Database.Execute("ALTER TABLE Products ADD CONSTRAINT UC_ProductName UNIQUE(Name);");
            }
            if (!dbSchema.TableExist <Order>())
            {
                dbSchema.CreateTable <Order>(false);
                dbSchema.CreateTable <OrderItem>(false);
            }
        }
コード例 #8
0
ファイル: DbStartup.cs プロジェクト: hoobarrr/UmbracoTinifier
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            var logger    = LoggerResolver.Current.Logger;
            var dbContext = applicationContext.DatabaseContext;
            var dbHelper  = new DatabaseSchemaHelper(dbContext.Database, logger, dbContext.SqlSyntax);

            if (!dbHelper.TableExist(PackageConstants.DbSettingsTable))
            {
                dbHelper.CreateTable <TSetting>(false);
            }

            if (!dbHelper.TableExist(PackageConstants.DbHistoryTable))
            {
                dbHelper.CreateTable <TinyPNGResponseHistory>(false);
            }

            if (!dbHelper.TableExist(PackageConstants.DbStatisticTable))
            {
                dbHelper.CreateTable <TImageStatistic>(false);
            }

            if (!dbHelper.TableExist(PackageConstants.DbStateTable))
            {
                dbHelper.CreateTable <TState>(false);
            }

            base.ApplicationStarted(umbracoApplication, applicationContext);
        }
コード例 #9
0
        //This happens everytime the Umbraco Application starts
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication,
                                                   ApplicationContext applicationContext)
        {
            //Get the Umbraco Database context
            var ctx = applicationContext.DatabaseContext;
            var db  = new DatabaseSchemaHelper(ctx.Database, applicationContext.ProfilingLogger.Logger, ctx.SqlSyntax);

            //Check if the DB table does NOT exist
            if (!db.TableExist(FortressConstants.TableNames.FortressUser2FASettings))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable <FortressUser2FASettings>(false);
            }

            /*   if (!db.TableExist(FortressConstants.TableNames.FortressLoginEvents))
             * {
             *     //Create DB table - and set overwrite to false
             *     db.CreateTable<FortressLoginEvent>(false);
             * }*/
            if (!db.TableExist(FortressConstants.TableNames.FortressSettings))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable <FortressSettingEntry>(false);

                FortressSettingEntry.InsertInitialSettings(ctx.Database, ApplicationContext.Current.DatabaseContext.SqlSyntax);
            }

            /*  if (!db.TableExist(FortressConstants.TableNames.FortressFirewallEntry))
             * {
             *    //Create DB table - and set overwrite to false
             *    db.CreateTable<FortressFirewallEntry>(false);
             * }*/
            FortressContext.Initialize();
        }
コード例 #10
0
        /// <summary>
        /// Nadpisanie metody ApplicationStarted
        /// Metoda zawiera customowe rozwiązania dla CMS
        /// </summary>
        /// <param name="umbracoApplication">obiekt UmbracoApplicationBase</param>
        /// <param name="applicationContext">obiekt ApplicationContext</param>
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            #region CustomTables
            var _db        = applicationContext.DatabaseContext.Database;
            var _logger    = LoggerResolver.Current.Logger;
            var _sqlSyntax = applicationContext.DatabaseContext.SqlSyntax;
            var _dbHelper  = new DatabaseSchemaHelper(_db, _logger, _sqlSyntax);

            if (!_dbHelper.TableExist("PolRegioRegion"))
            {
                _dbHelper.CreateTable <RegionDB>(true);
            }

            if (!_dbHelper.TableExist("PolRegioArticleType"))
            {
                _dbHelper.CreateTable <ArticleTypeDB>(true);
            }

            if (!_dbHelper.TableExist("PolRegioAdministrative"))
            {
                _dbHelper.CreateTable <AdministrativeDB>(true);
            }
            #endregion

            var _contentServiceEvents = new ContentServiceEvents(applicationContext);
            ContentService.Saved += _contentServiceEvents.ContentService_Saved;
        }
コード例 #11
0
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            var dbContext = applicationContext.DatabaseContext;
            var db        = new DatabaseSchemaHelper(dbContext.Database, applicationContext.ProfilingLogger.Logger, dbContext.SqlSyntax);

            if (!db.TableExist <Booking>())
            {
                db.CreateTable <Booking>();
            }

            if (!db.TableExist <Token>())
            {
                db.CreateTable <Token>();
            }

            if (!db.TableExist <SummaryEmail>())
            {
                db.CreateTable <SummaryEmail>();
            }

            if (!db.TableExist <NewBookingEmail>())
            {
                db.CreateTable <NewBookingEmail>();
            }
        }
コード例 #12
0
ファイル: DatabaseHelper.cs プロジェクト: umweltdk/LeBlender
        public bool CreateTables()
        {
            var importConfig = false;

            try
            {
                var schema = new DatabaseSchemaHelper(dbContext.Database, ApplicationContext.Current.ProfilingLogger.Logger, dbContext.SqlSyntax);
                if (!schema.TableExist("LeBlenderGridEditor"))
                {
                    schema.CreateTable <LeBlenderGridEditorModel>(false);
                    importConfig = true;
                }
                if (!schema.TableExist("LeBlenderConfig"))
                {
                    schema.CreateTable <LeBlenderConfigModel>(false);
                }
                if (!schema.TableExist("LeBlenderProperty"))
                {
                    schema.CreateTable <LeBlenderPropertyModel>(false);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error <DatabaseHelper>($"Error while creating database tables", ex);
            }
            return(importConfig);
        }
コード例 #13
0
 /// <summary>
 /// Add changes
 /// </summary>
 public override void Up()
 {
     // Check if the table notelyNotes exits
     if (_schemaHelper.TableExist("notelyNotes"))
     {
         Alter.Table("notelyNotes").AddColumn("priority").AsInt32().NotNullable().WithDefaultValue(1);
     }
 }
コード例 #14
0
        public void Can_Assert_Created_Database()
        {
            string path = TestHelper.CurrentAssemblyDirectory;

            AppDomain.CurrentDomain.SetData("DataDirectory", path);

            //Delete database file before continueing
            //NOTE: we'll use a custom db file for this test since we're re-using the one created with BaseDatabaseFactoryTest
            string filePath = string.Concat(path, "\\DatabaseContextTests.sdf");

            if (File.Exists(filePath))
            {
                File.Delete(filePath);
            }

            //Get the connectionstring settings from config
            var settings = ConfigurationManager.ConnectionStrings[Constants.System.UmbracoConnectionName];

            //by default the conn string is: Datasource=|DataDirectory|UmbracoPetaPocoTests.sdf;Flush Interval=1;
            //we'll just replace the sdf file with our custom one:
            //Create the Sql CE database
            var connString = settings.ConnectionString.Replace("UmbracoPetaPocoTests", "DatabaseContextTests");

            using (var engine = new SqlCeEngine(connString))
            {
                engine.CreateDatabase();
            }

            var dbFactory     = new DefaultDatabaseFactory(connString, Constants.DatabaseProviders.SqlCe, Mock.Of <ILogger>());
            var scopeProvider = new ScopeProvider(dbFactory);

            //re-map the dbcontext to the new conn string
            _dbContext = new DatabaseContext(
                scopeProvider,
                Mock.Of <ILogger>(),
                new SqlCeSyntaxProvider(),
                dbFactory.ProviderName);

            var schemaHelper = new DatabaseSchemaHelper(_dbContext.Database, Mock.Of <ILogger>(), new SqlCeSyntaxProvider());

            var appCtx = new ApplicationContext(
                _dbContext,
                new ServiceContext(migrationEntryService: Mock.Of <IMigrationEntryService>()),
                CacheHelper.CreateDisabledCacheHelper(),
                new ProfilingLogger(Mock.Of <ILogger>(), Mock.Of <IProfiler>()));

            //Create the umbraco database
            schemaHelper.CreateDatabaseSchema(false, appCtx);

            bool umbracoNodeTable = schemaHelper.TableExist("umbracoNode");
            bool umbracoUserTable = schemaHelper.TableExist("umbracoUser");
            bool cmsTagsTable     = schemaHelper.TableExist("cmsTags");

            Assert.That(umbracoNodeTable, Is.True);
            Assert.That(umbracoUserTable, Is.True);
            Assert.That(cmsTagsTable, Is.True);
        }
コード例 #15
0
        /// <summary>
        /// Creates the Configuration table
        /// </summary>
        public override void Up()
        {
            //  Environment
            if (_schemaHelper.TableExist <Dto.Environment.Environment100>())
            {
                var sql = new Sql().Where("id != 1");
                _database.Delete <Dto.Environment.Environment100>(sql);

                Alter.Table <Dto.Environment.Environment103>().AddColumn(nameof(Dto.Environment.Environment103.SortOrder)).AsInt32().NotNullable().WithDefaultValue(Constants.Tree.DefaultEnvironmentSortOrder);
                Alter.Table <Dto.Environment.Environment103>().AddColumn(nameof(Dto.Environment.Environment103.Enable)).AsBoolean().NotNullable().WithDefaultValue(true);
                Alter.Table <Dto.Environment.Environment103>().AddColumn(nameof(Dto.Environment.Environment103.ContinueProcessing)).AsBoolean().NotNullable().WithDefaultValue(true);
                Alter.Table <Dto.Environment.Environment103>().AddColumn(nameof(Dto.Environment.Environment103.ColorIndicator)).AsString(7).NotNullable().WithDefaultValue("#df7f48");
            }
            else
            {
                _schemaHelper.CreateTable <Dto.Environment.Environment103>();
                _database.Insert(new Dto.Environment.Environment103
                {
                    Name               = "Default",
                    Icon               = "icon-firewall red",
                    Enable             = true,
                    ContinueProcessing = true,
                    SortOrder          = Constants.Tree.DefaultEnvironmentSortOrder,
                    ColorIndicator     = "#df7f48"
                });
            }

            //  Domain
            if (!_schemaHelper.TableExist <Dto.Domain.Domain100>())
            {
                _schemaHelper.CreateTable <Dto.Domain.Domain100>();
            }

            //  Configuration
            if (!_schemaHelper.TableExist <Dto.Configuration.Configuration100>())
            {
                _schemaHelper.CreateTable <Dto.Configuration.Configuration103>();
            }

            //  Journal
            if (_schemaHelper.TableExist <Dto.Journal.Journal100>())
            {
                Delete.Index("IX_" + nameof(Shield) + "_" + nameof(Dto.Journal.Journal100.Datestamp)).OnTable <Dto.Journal.Journal100>();
                Create.Index("IX_" + nameof(Shield) + "_" + nameof(Dto.Journal.Journal103.Datestamp)).OnTable <Dto.Journal.Journal103>()
                .OnColumn(nameof(Dto.Journal.Journal103.Datestamp)).Ascending().WithOptions().NonClustered();
            }
            else
            {
                _schemaHelper.CreateTable <Dto.Journal.Journal103>();
            }
        }
コード例 #16
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)"));
                    }
                }
            }
        }
コード例 #17
0
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            var ctx = applicationContext.DatabaseContext;
            var db  = new DatabaseSchemaHelper(ctx.Database, applicationContext.ProfilingLogger.Logger, ctx.SqlSyntax);

            if (!db.TableExist("CMSPoints"))
            {
                db.CreateTable <Points>(false);
            }
            if (!db.TableExist("CMSStateInfo"))
            {
                db.CreateTable <States>(false);
            }
        }
コード例 #18
0
        private void CreateTables()
        {
            if (!_schemaHelper.TableExist(accountsTableName))
            {
                Logger.Info <CreateInitialTables>("Creation Accounts Table");
                _schemaHelper.CreateTable <Account>();
            }

            if (!_schemaHelper.TableExist(accountSettingsTableName))
            {
                Logger.Info <CreateInitialTables>("Creating AccountSettings Table");
                _schemaHelper.CreateTable <AccountSettings>();
            }
        }
コード例 #19
0
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            var dbContext = applicationContext.DatabaseContext;
            var db        = new DatabaseSchemaHelper(dbContext.Database, applicationContext.ProfilingLogger.Logger, dbContext.SqlSyntax);

            // automatically create the tables for the index on app start
            if (db.TableExist("FormEditorEntries") == false)
            {
                db.CreateTable <Entry>(false);
            }
            if (db.TableExist("FormEditorFiles") == false)
            {
                db.CreateTable <File>(false);
            }
        }
コード例 #20
0
        public void CreateTableOfTDto()
        {
            var logger = new DebugDiagnosticsLogger();

            var migrationRunner = new MigrationRunner(
                Mock.Of <IMigrationEntryService>(),
                logger,
                new SemVersion(0, 0, 0),
                new SemVersion(1, 0, 0),
                "Test",

                // explicit migrations
                new CreateTableOfTDtoMigration(SqlSyntax, logger)
                );

            var db = new UmbracoDatabase("Datasource=|DataDirectory|UmbracoPetaPocoTests.sdf;Flush Interval=1;", Constants.DatabaseProviders.SqlCe, Logger);

            var upgraded = migrationRunner.Execute(db, DatabaseProviders.SqlServerCE, true);

            Assert.IsTrue(upgraded);

            var helper = new DatabaseSchemaHelper(db, logger, SqlSyntax);
            var exists = helper.TableExist("umbracoNode");

            Assert.IsTrue(exists);
        }
コード例 #21
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);
                }
            }
        }
コード例 #22
0
 /// <summary>
 /// Adds the table to the database
 /// </summary>
 public void Up()
 {
     if (!_schemaHelper.TableExist("merchCustomer2EntityCollection"))
     {
         _schemaHelper.CreateTable(false, typeof(Customer2EntityCollectionDto));
     }
 }
コード例 #23
0
 /// <summary>
 /// Adds the indexes to the merchDigitalMedia table.
 /// </summary>
 public override void Up()
 {
     if (!_schemaHelper.TableExist("merchDigitalMedia"))
     {
         _schemaHelper.CreateTable(false, typeof(DigitalMediaDto));
     }
 }
コード例 #24
0
        private async Task DisplaySignedFor()
        {
            try
            {
                if (!dbSchemaHelper.TableExist(DeliveryDeliverable.TableName))
                {
                    await Out.WriteLineAsync("The target database hasn't had `delivery` run against it as there's no tracking table");
                    return;
                }
            }
            catch (DbException)
            {
                await Out.WriteLineAsync("There was an error checking for the database Chauffeur Delivery tracking table, most likely your connection string is invalid or your database doesn't exist.");
                return;
            }

            var sql = new Sql()
                .From<ChauffeurDeliveryTable>(sqlSyntax);

            var results = database.Fetch<ChauffeurDeliveryTable>(sql);

            if (results.Count == 0)
                await Out.WriteLineAsync("No deliveries have previously been signed for.");
            else
                await Out.WriteTableAsync(
                    results.Select(t => new
                    {
                        t.Name,
                        Date = t.ExecutionDate.ToString("yyy-MM-dd hh:ss"),
                        t.Hash
                    })
                );
        }
 /// <summary>
 /// Adds the new table to the database.
 /// </summary>
 public override void Up()
 {
     if (!_schemaHelper.TableExist("merchProductOptionAttributeShare"))
     {
         _schemaHelper.CreateTable(false, typeof(ProductOptionAttributeShareDto));
     }
 }
コード例 #26
0
        private void CreateTinifierTables()
        {
            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.CreateTable(false, tables.ElementAt(i).Value);
                }
            }

            // migrations
            foreach (var migration in Application.Migrations.MigrationsHelper.GetAllMigrations())
            {
                migration?.Resolve(dbContext);
            }
        }
コード例 #27
0
 /// <summary>
 /// Creates the ProductVariant2DetachedContentType table
 /// </summary>
 public void Up()
 {
     if (!_schemaHelper.TableExist("merchProductVariantDetachedContent"))
     {
         _schemaHelper.CreateTable(false, typeof(ProductVariantDetachedContentDto));
     }
 }
コード例 #28
0
        /// <summary>
        /// Gets an array of all domains from the database.
        /// </summary>
        /// <returns>An array of <see cref="RedirectDomain"/>.</returns>
        public RedirectDomain[] GetAllDomains()
        {
            // Just return an empty array if the table doesn't exist (since there aren't any domains anyway)
            if (!SchemaHelper.TableExist(RedirectDomain.TableName))
            {
                return(new RedirectDomain[0]);
            }

            // Generate the SQL for the query
            Sql sql = new Sql().Select("*").From(RedirectDomain.TableName);

            // Make the call to the database
            RedirectDomain[] all = Database.Fetch <RedirectDomain>(sql).ToArray();

            return(all);
        }
コード例 #29
0
ファイル: DbReceives.cs プロジェクト: simonelmqvist/CarRental
 public void CreateTabelIfNone()
 {
     if (!_dbSchemaHelper.TableExist(_tableName))
     {
         _dbSchemaHelper.CreateTable <ReceiveDbModel>(false);
     }
 }
コード例 #30
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);
                }
            }
        }
コード例 #31
0
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            DatabaseContext      ctx      = ApplicationContext.Current.DatabaseContext;
            DatabaseSchemaHelper dbSchema = new DatabaseSchemaHelper(ctx.Database, ApplicationContext.Current.ProfilingLogger.Logger, ctx.SqlSyntax);


            if (!dbSchema.TableExist("CompanyInvetoryAudit"))
            {
                dbSchema.CreateTable <CompanyInvetoryAudit>(false);
            }

            if (!dbSchema.TableExist("CompanyInventory"))
            {
                dbSchema.CreateTable <CompanyInventory>(false);
            }
        }
コード例 #32
0
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            var dbContext = applicationContext.DatabaseContext;
            var db = new DatabaseSchemaHelper(dbContext.Database, applicationContext.ProfilingLogger.Logger, dbContext.SqlSyntax);

            // automatically create the tables for the index on app start
            if (db.TableExist("FormEditorEntries") == false)
            {
                db.CreateTable<Entry>(false);
                // hack to get SQL server to use NVARCHAR(MAX) datatype
                dbContext.Database.Execute("ALTER TABLE FormEditorEntries ALTER COLUMN FieldValues NVARCHAR(MAX)");
            }
            if (db.TableExist("FormEditorFiles") == false)
            {
                db.CreateTable<File>(false);
            }
        }
コード例 #33
0
        /// <summary>
        /// On Application Started we need to ensure that the Redirects table exists. If not, create it
        /// </summary>
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            //Grab the Umbraco database context and spin up a new DatabaseSchemaHelper
            var db = applicationContext.DatabaseContext.Database;
            var creator = new DatabaseSchemaHelper(db, LoggerResolver.Current.Logger, SqlSyntaxContext.SqlSyntaxProvider);

            //Ensure the Redirects table exists. If not, create it
            if (!creator.TableExist("Redirects"))
                creator.CreateTable<Redirect>(false);
        }
コード例 #34
0
ファイル: EasyADApplication.cs プロジェクト: ThumNet/EasyAD
        internal static void CreateTables(ApplicationContext applicationContext)
        {
            //Get the Umbraco Database context
            var ctx = applicationContext.DatabaseContext;
            var db = new DatabaseSchemaHelper(ctx.Database, applicationContext.ProfilingLogger.Logger, ctx.SqlSyntax);

            LogHelper.Info<EasyADApplication>("Creating EasyAD tables");

            //Check if the DB table does NOT exist
            if (!db.TableExist(AppConstants.TableNames.EasyADGroups))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<EasyADGroup>(false);
            }

            //Check if the DB table does NOT exist
            if (!db.TableExist(AppConstants.TableNames.EasyADGroup2Users))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<EasyADGroup2User>(false);
            }
        }
コード例 #35
0
 protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     TreeControllerBase.TreeNodesRendering += TreeControllerBase_TreeNodesRendering;
     var ctx = ApplicationContext.Current.DatabaseContext;
     var db = new DatabaseSchemaHelper(ctx.Database, applicationContext.ProfilingLogger.Logger, ctx.SqlSyntax);
     //Check if the DB table does NOT exist
     if (!db.TableExist("LookWhosEditingNow"))
     {
         //Create DB table - and set overwrite to false
         db.CreateTable<Edit>(false);
     }
     //Install dashboard
     AddStartUpSectionDashboard();
 }
コード例 #36
0
        /// <summary>
        /// Updates the column size
        /// </summary>
        public override void Up()
        {
            var database = ApplicationContext.Current.DatabaseContext.Database;

            var databaseSchemaHelper = new DatabaseSchemaHelper(database, this.Logger, this.SqlSyntax);
            if (databaseSchemaHelper.TableExist("merchAppliedPayment"))
            {
                // Add another assertion that the field size has not already been changed to 500
                // and some other migration failed which flagged the version to 2.2.0 or earlier
                var size = database.GetDbTableColumnSize("merchAppliedPayment", "description");

                if (size == 500) return;

                // Update the column to allow for 500 characters instead of 255 which proved too small
                Alter.Table("merchAppliedPayment").AlterColumn("description").AsString(500).NotNullable();
            }
        }
コード例 #37
0
        /// <summary>
        /// Updates the merchProductAttribute table altering detachedContentValues to NTEXT.
        /// </summary>
        public override void Up()
        {
            var database = ApplicationContext.Current.DatabaseContext.Database;

            var databaseSchemaHelper = new DatabaseSchemaHelper(database, this.Logger, this.SqlSyntax);
            if (databaseSchemaHelper.TableExist("merchProductAttribute"))
            {
                // Add another assertion that the field size has not already been changed to NTEXT
                // and some other migration failed which flagged the version to 2.3.0 or earlier
                var size = database.GetDbTableColumnSize("merchProductAttribute", "detachedContentValues");

                if (size > 500) return;

                // Update the column to be NTEXT instead of 255 - BUG FIX
                var textType = this.SqlSyntax.GetSpecialDbType(SpecialDbTypes.NTEXT);
                Alter.Table("merchProductAttribute").AlterColumn("detachedContentValues").AsCustom(textType).Nullable();
            }

            Logger.Debug<AlterProductAttributeColumnToNtext>("AlterProductAttributeColumnToNtext has been called.");
        }
コード例 #38
0
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            //Get the Umbraco Database context
            var ctx = applicationContext.DatabaseContext;
            var db = new DatabaseSchemaHelper(ctx.Database, applicationContext.ProfilingLogger.Logger, ctx.SqlSyntax);

            //Check if the DB table does NOT exist
            if (!db.TableExist("JobsplusRegions"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<Region>(false);
            }

            //Check if the DB table does NOT exist
            if (!db.TableExist("JobsplusDistricts"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<District>(false);
            }

            //Check if the DB table does NOT exist
            if (!db.TableExist("JobsplusGrants"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<Grant>(false);
            }

            //Check if the DB table does NOT exist
            if (!db.TableExist("JobsplusEmployDepartments"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<EmployDepartment>(false);
            }

            //Check if the DB table does NOT exist
            if (!db.TableExist("JobsplusGrantDefinitions"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<GrantDefinition>(false);
            }

            //Check if the DB table does NOT exist
            /*
            if (!db.TableExist("JobsplusGrantsGrantDefinitions"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<GrantGrantDefinition>(false);
            }
             */

            if (!db.TableExist("JobsplusGrantDefEmployDeparts"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<GrantDefEmployDeparts>(false);
            }

            //Check if the DB table does NOT exist
            if (!db.TableExist("JobsplusSpecializations"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<Specialization>(false);
            }

            //Check if the DB table does NOT exist
            if (!db.TableExist("JobsplusJobs"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<Job>(false);
            }

            //Check if the DB table does NOT exist
            if (!db.TableExist("JobsplusJobTemplates"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<JobTemplate>(false);
            }

            //Check if the DB table does NOT exist
            if (!db.TableExist("JobsplusAdvertisementReply"))
            {
                //Create DB table - and set overwrite to false
                db.CreateTable<AdvertisementReply>(false);
            }
        }