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);
            }
        }
        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));
            }
        }
Example #3
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);
            }
        }
Example #4
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);
            }
        }
Example #5
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);
                }
            }
        }
Example #6
0
        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);
        }
Example #7
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;
        }
Example #8
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>();
            }
        }
Example #9
0
        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);
        }
Example #10
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));
            }
        }
        //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();
        }
Example #12
0
        /// <summary>
        /// Creates the table for the specified object type.
        /// </summary>
        /// <typeparam name="T">The object type.</typeparam>
        public void CreateTable <T>()
            where T : new()
        {
            if (TableExists <T>())
            {
                return;
            }

            _databaseSchemaHelper.CreateTable <T>();
        }
Example #13
0
 public override void Up()
 {
     try
     {
         _sh.CreateTable <NovicellMapBuilderMapsModel>(false);
         _sh.CreateTable <NovicellMapBuilderDataModel>(false);
     }
     catch (Exception e)
     {
         _logger.Error <MapBuilderMigration>("Error creating tables for NcMapBuilder", e);
     }
 }
        /// <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>();
            }
        }
 /// <inheritdoc />
 protected override void ApplicationStarted(
     UmbracoApplicationBase umbracoApplication,
     ApplicationContext applicationContext)
 {
     if (applicationContext.IsConfigured)
     {
         var ctx = applicationContext.DatabaseContext;
         var db  = new DatabaseSchemaHelper(ctx.Database, applicationContext.ProfilingLogger.Logger, ctx.SqlSyntax);
         db.CreateTable <ClaremontEvent>(false);
         db.CreateTable <Participant>(false);
         db.CreateTable <Notification>(false);
         db.CreateTable <JobInfo>(false);
     }
 }
Example #16
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);
            }
        }
Example #17
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>();
            }
        }
Example #18
0
        public override void Up()
        {
            try
            {
                //	Create tables
                _schemaHelper.CreateTable <Dto.Entry.Entry100>();
                _schemaHelper.CreateTable <Dto.Ancestor.Ancestor100>();

                //	Scrape all existing content and place into the index
                var ancestorDb     = new AncestorContext();
                var entryDb        = new EntryContext();
                var now            = DateTime.UtcNow;
                var contents       = new Stack <Umbraco.Core.Models.IContent>();
                var contentService = ApplicationContext.Current.Services.ContentService;

                foreach (var content in contentService.GetChildren(Umbraco.Core.Constants.System.Root))
                {
                    if (content.Published)
                    {
                        contents.Push(content);
                    }
                }

                while (contents.Count != 0)
                {
                    var content = contents.Pop();
                    foreach (var child in contentService.GetChildren(content.Id))
                    {
                        if (child.Published)
                        {
                            contents.Push(child);
                        }
                    }
                    foreach (var entry in new ContentService().Entries(new Umbraco.Core.Models.IContent[] { content }))
                    {
                        entryDb.Write(entry.Key, entry.Id, entry.Map, now);
                        ancestorDb.Write(entry.Id, entry.Key, now);
                        foreach (var ancestor in entry.Ancestors)
                        {
                            ancestorDb.Write(ancestor, entry.Key, now);
                        }
                    }
                    System.Threading.Thread.Sleep(50);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error <SqlIndexer>($"Error trying to create content with indexer", ex);
            }
        }
Example #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);
            }
        }
        /// <summary>
        /// When umbraco has started up
        /// </summary>
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            // Store our JWT secret somewhere safe before adding it to the Env variable.
            // This allows us to move the project between environments and maintain the
            // same secret. This should ideally be in a config file of its own so
            // we can ignore it from source control etc. but we're just going to use
            // AppSettings for now...
            Configuration config = WebConfigurationManager.OpenWebConfiguration("/");

            if (config.AppSettings.Settings["JWT:Secret"] == null)
            {
                config.AppSettings.Settings.Add("JWT:Secret", Membership.GeneratePassword(50, 5));
                config.Save(ConfigurationSaveMode.Modified);
            }

            //When Umbraco Started lets check for DB table exists
            var dbContext = applicationContext.DatabaseContext;
            var db        = new DatabaseSchemaHelper(dbContext.Database, applicationContext.ProfilingLogger.Logger, dbContext.SqlSyntax);

            //If table does not exist
            if (!db.TableExist("identityAuthTokens"))
            {
                //Create Table - do not override
                db.CreateTable <UmbracoAuthToken>(false);
            }

            //Add event to saving/chaning pasword on Umbraco backoffice user
            UserService.SavingUser += UserService_SavingUser;

            //Add event to saving/chaning pasword on Umbraco member
            MemberService.Saving += MemberService_Saving;

            //Continue as normal
            base.ApplicationStarted(umbracoApplication, applicationContext);
        }
 /// <summary>
 /// Adds the indexes to the merchDigitalMedia table.
 /// </summary>
 public override void Up()
 {
     if (!_schemaHelper.TableExist("merchDigitalMedia"))
     {
         _schemaHelper.CreateTable(false, typeof(DigitalMediaDto));
     }
 }
Example #22
0
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            var ctx = applicationContext.DatabaseContext;
            var db  = new DatabaseSchemaHelper(ctx.Database, applicationContext.ProfilingLogger.Logger, ctx.SqlSyntax);

            db.CreateTable <Person>(false);
        }
        public override void Up()
        {
            var schemaHelper = new DatabaseSchemaHelper(Context.Database, Logger, SqlSyntax);

            //NOTE: This isn't the correct way to do this but to manually create this table with the Create syntax is a pain in the arse
            schemaHelper.CreateTable <ServerRegistrationDto>();
        }
Example #24
0
 public void CreateTabelIfNone()
 {
     if (!_dbSchemaHelper.TableExist(_tableName))
     {
         _dbSchemaHelper.CreateTable <ReceiveDbModel>(false);
     }
 }
 /// <summary>
 /// Adds the new table to the database.
 /// </summary>
 public override void Up()
 {
     if (!_schemaHelper.TableExist("merchProductOptionAttributeShare"))
     {
         _schemaHelper.CreateTable(false, typeof(ProductOptionAttributeShareDto));
     }
 }
 /// <summary>
 /// Performs the task of adding the table.
 /// </summary>
 public void Up()
 {
     if (!_schemaHelper.TableExist("merchNote"))
     {
         _schemaHelper.CreateTable(false, typeof(NoteDto));
     }
 }
Example #27
0
 /// <summary>
 /// The up.
 /// </summary>
 public void Up()
 {
     foreach (var item in OrderedTables.OrderBy(x => x.Key))
     {
         _schemaHelper.CreateTable(false, item.Value);
     }
 }
 /// <summary>
 /// Adds the table to the database
 /// </summary>
 public void Up()
 {
     if (!_schemaHelper.TableExist("merchCustomer2EntityCollection"))
     {
         _schemaHelper.CreateTable(false, typeof(Customer2EntityCollectionDto));
     }
 }
 /// <summary>
 /// Creates the ProductVariant2DetachedContentType table
 /// </summary>
 public void Up()
 {
     if (!_schemaHelper.TableExist("merchProductVariantDetachedContent"))
     {
         _schemaHelper.CreateTable(false, typeof(ProductVariantDetachedContentDto));
     }
 }
        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);
            }
        }
Example #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);
            }
        }
Example #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);
            }
        }
        /// <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);
        }
Example #34
0
        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);
            }
        }
 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();
 }
        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);
            }
        }
 /// <summary>
 /// Modifies the database (e.g., adding necessary tables).
 /// </summary>
 /// <param name="applicationContext">
 /// The application context.
 /// </param>
 private void InitializeDatabase(ApplicationContext applicationContext)
 {
     var dbContext = applicationContext.DatabaseContext;
     var logger = applicationContext.ProfilingLogger.Logger;
     var db = dbContext.Database;
     var dbHelper = new DatabaseSchemaHelper(db, logger, dbContext.SqlSyntax);
     try
     {
         dbHelper.CreateTable<FormulateSubmission>();
     }
     catch (Exception ex)
     {
         LogHelper.Error<ApplicationStartedHandler>(TableCreationError, ex);
     }
 }