public override void Up() { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("cmsMacro") && x.ColumnName.InvariantEquals("uniqueId")) == false) { Create.Column("uniqueId").OnTable("cmsMacro").AsGuid().Nullable(); Execute.Code(UpdateMacroGuids); Alter.Table("cmsMacro").AlterColumn("uniqueId").AsGuid().NotNullable(); Create.Index("IX_cmsMacro_UniqueId").OnTable("cmsMacro").OnColumn("uniqueId") .Ascending() .WithOptions().NonClustered() .WithOptions().Unique(); } if (columns.Any(x => x.TableName.InvariantEquals("cmsMacroProperty") && x.ColumnName.InvariantEquals("uniquePropertyId")) == false) { Create.Column("uniquePropertyId").OnTable("cmsMacroProperty").AsGuid().Nullable(); Execute.Code(UpdateMacroPropertyGuids); Alter.Table("cmsMacroProperty").AlterColumn("uniquePropertyId").AsGuid().NotNullable(); Create.Index("IX_cmsMacroProperty_UniquePropertyId").OnTable("cmsMacroProperty").OnColumn("uniquePropertyId") .Ascending() .WithOptions().NonClustered() .WithOptions().Unique(); } }
public override void Up() { //Don't exeucte if the column is already there var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("securityStampToken")) == false) { Create.Column("securityStampToken").OnTable("umbracoUser").AsString(255).Nullable(); } if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("failedLoginAttempts")) == false) { Create.Column("failedLoginAttempts").OnTable("umbracoUser").AsInt32().Nullable(); } if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("lastLockoutDate")) == false) { Create.Column("lastLockoutDate").OnTable("umbracoUser").AsDateTime().Nullable(); } if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("lastPasswordChangeDate")) == false) { Create.Column("lastPasswordChangeDate").OnTable("umbracoUser").AsDateTime().Nullable(); } if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("lastLoginDate")) == false) { Create.Column("lastLoginDate").OnTable("umbracoUser").AsDateTime().Nullable(); } }
public override void Migrate() { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToList(); AddColumnIfNotExists <PropertyTypeDto>(columns, "mandatoryMessage"); AddColumnIfNotExists <PropertyTypeDto>(columns, "validationRegExpMessage"); }
/// <summary> /// Updates the merchProductAttribute table adding the columns. /// </summary> public override void Up() { var database = ApplicationContext.Current.DatabaseContext.Database; var columns = SqlSyntax.GetColumnsInSchema(database).ToArray(); // 'shared' column if (columns.Any( x => x.TableName.InvariantEquals("merchProductAttribute") && x.ColumnName.InvariantEquals("detachedContentValues")) == false) { Logger.Info(typeof(AddProductAttributeColumns), "Adding detachedContentValues column to merchProductAttribute table."); //// Add the new 'shared' column var textType = SqlSyntax.GetSpecialDbType(SpecialDbTypes.NTEXT); Create.Column("detachedContentValues").OnTable("merchProductAttribute").AsCustom(textType).Nullable(); } // 'isDefaultChoice' column if (columns.Any( x => x.TableName.InvariantEquals("merchProductAttribute") && x.ColumnName.InvariantEquals("isDefaultChoice")) == false) { Logger.Info(typeof(AddProductAttributeColumns), "Adding isDefaultChoice column to merchProductAttribute table."); //// Add the new 'isDefaultChoice' column Create.Column("isDefaultChoice").OnTable("merchProductAttribute").AsBoolean().WithDefaultValue(false); } }
protected string ColumnType(string tableName, string columnName) { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).Distinct().ToArray(); var column = columns.FirstOrDefault(x => x.TableName.InvariantEquals(tableName) && x.ColumnName.InvariantEquals(columnName)); return(column?.DataType); }
public override void Migrate() { var tables = SqlSyntax.GetTablesInSchema(Context.Database).ToList(); var constraints = SqlSyntax.GetConstraintsPerColumn(Context.Database).Distinct().ToArray(); var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); //In some very rare cases, there might alraedy be user group tables that we'll need to remove first //but of course we don't want to remove the tables we will be creating below if they already exist so //need to do some checks first since these old rare tables have a different schema RemoveOldTablesIfExist(tables, columns); if (AddNewTables(tables)) { MigrateUserPermissions(); MigrateUserTypesToGroups(); DeleteOldTables(tables, constraints); SetDefaultIcons(); } else { //if we aren't adding the tables, make sure that the umbracoUserGroup table has the correct FKs - these //were added after the beta release so we need to do some cleanup //if the FK doesn't exist if (constraints.Any(x => x.Item1.InvariantEquals("umbracoUserGroup") && x.Item2.InvariantEquals("startContentId") && x.Item3.InvariantEquals("FK_startContentId_umbracoNode_id")) == false) { //before we add any foreign key we need to make sure there's no stale data in there which would have happened in the beta //release if a start node was assigned and then that start node was deleted. Database.Execute(@"UPDATE umbracoUserGroup SET startContentId = NULL WHERE startContentId NOT IN (SELECT id FROM umbracoNode)"); Create.ForeignKey("FK_startContentId_umbracoNode_id") .FromTable("umbracoUserGroup") .ForeignColumn("startContentId") .ToTable("umbracoNode") .PrimaryColumn("id") .OnDelete(Rule.None) .OnUpdate(Rule.None) .Do(); } if (constraints.Any(x => x.Item1.InvariantEquals("umbracoUserGroup") && x.Item2.InvariantEquals("startMediaId") && x.Item3.InvariantEquals("FK_startMediaId_umbracoNode_id")) == false) { //before we add any foreign key we need to make sure there's no stale data in there which would have happened in the beta //release if a start node was assigned and then that start node was deleted. Database.Execute(@"UPDATE umbracoUserGroup SET startMediaId = NULL WHERE startMediaId NOT IN (SELECT id FROM umbracoNode)"); Create.ForeignKey("FK_startMediaId_umbracoNode_id") .FromTable("umbracoUserGroup") .ForeignColumn("startMediaId") .ToTable("umbracoNode") .PrimaryColumn("id") .OnDelete(Rule.None) .OnUpdate(Rule.None) .Do(); } } }
public override void Up() { //Don't exeucte if the column is already there ColumnInfo[] columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("WorkflowInstance") && x.ColumnName.InvariantEquals("CompletedDate")) == false) { Create.Column("CompletedDate").OnTable("WorkflowInstance").AsDateTime().Nullable(); } // once the column has been added, check for any instances where status is not active, find the last task, and set complete date to match // this only impacts on charting, but allows more complete history as instances didn't previously store a completion date var instances = Pr.GetAllInstances() .OrderByDescending(x => x.CreatedDate) .Where(x => x.Status != (int)WorkflowStatus.PendingApproval && x.Status != (int)WorkflowStatus.NotRequired) .ToList(); foreach (var instance in instances) { var finalTask = instance.TaskInstances.LastOrDefault(); if (null != finalTask) { instance.CompletedDate = finalTask.CompletedDate; Context.Database.Update(instance); } } }
public override void Up() { if (SqlSyntax.GetColumnsInSchema(Context.Database).Any(x => x.TableName.InvariantEquals("umbracoUserLogins"))) { Delete.Table("umbracoUserLogins"); } }
protected bool ColumnExists(string tableName, string columnName) { // that's ok even on MySql var columns = SqlSyntax.GetColumnsInSchema(Context.Database).Distinct().ToArray(); return(columns.Any(x => x.TableName.InvariantEquals(tableName) && x.ColumnName.InvariantEquals(columnName))); }
protected override void Migrate() { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToList(); AddColumnIfNotExists <LogDto>(columns, "entityType"); AddColumnIfNotExists <LogDto>(columns, "parameters"); }
/// <summary> /// Adds new columns to members table /// </summary> protected override void Migrate() { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToList(); AddColumnIfNotExists <MemberDto>(columns, "securityStampToken"); AddColumnIfNotExists <MemberDto>(columns, "emailConfirmedDate"); }
protected override void Migrate() { AlterColumn <ContentNuDto>(Constants.DatabaseSchema.Tables.NodeData, "data"); var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToList(); AddColumnIfNotExists <ContentNuDto>(columns, "dataRaw"); }
public override void Migrate() { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals(Constants.DatabaseSchema.Tables.User) && x.ColumnName.InvariantEquals("tourData")) == false) { AddColumn <UserDto>("tourData"); } }
public override void Migrate() { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals(Constants.DatabaseSchema.Tables.MemberType) && x.ColumnName.InvariantEquals("isSensitive")) == false) { AddColumn <MemberTypeDto>("isSensitive"); } }
protected override void Migrate() { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals(Cms.Core.Constants.DatabaseSchema.Tables.Language) && x.ColumnName.InvariantEquals("fallbackLanguageId")) == false) { AddColumn <LanguageDto>("fallbackLanguageId"); } }
public override void Up() { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).Distinct().ToArray(); if (columns.Any(x => x.ColumnName.InvariantEquals("alias") && x.TableName.InvariantEquals("cmsDocument"))) { Delete.Column("alias").FromTable("cmsDocument"); } }
public override void Migrate() { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals(Constants.DatabaseSchema.Tables.CacheInstruction) && x.ColumnName.InvariantEquals("instructionCount")) == false) { AddColumn <CacheInstructionDto>("instructionCount"); } }
public override void Up() { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).Distinct().ToArray(); if (columns.Any(x => x.ColumnName.InvariantEquals("LanguageLocale") && x.TableName.InvariantEquals("cmsContentVersion"))) { Delete.Column("LanguageLocale").FromTable("cmsContentVersion"); } }
public override void Up() { //Don't exeucte if the column is already there var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("cmsPropertyData") && x.ColumnName.InvariantEquals("dataDecimal")) == false) { Create.Column("dataDecimal").OnTable("cmsPropertyData").AsDecimal().Nullable(); } }
/// <summary> /// The up. /// </summary> public override void Up() { //// Don't exeucte if the column is already there var columns = SqlSyntax.GetColumnsInSchema(_database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("merchCustomer") && x.ColumnName.InvariantEquals("notes") == false)) { Create.Column("notes").OnTable("merchCustomer").AsString().Nullable(); } }
public override void Up() { //Don't exeucte if the column is already there var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("cmsMemberType") && x.ColumnName.InvariantEquals("isSensitive")) == false) { Create.Column("isSensitive").OnTable("cmsMemberType").AsBoolean().WithDefaultValue(0).NotNullable(); } }
public override void Up() { //Don't exeucte if the column is already there ColumnInfo[] columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("WorkflowSettings") && x.ColumnName.InvariantEquals("LockIfActive")) == false) { Create.Column("LockIfActive").OnTable("WorkflowSettings").AsBoolean().Nullable(); } }
public override void Up() { //Don't exeucte if the column is already there var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("umbracoUser") && x.ColumnName.InvariantEquals("tourData")) == false) { var textType = SqlSyntax.GetSpecialDbType(SpecialDbTypes.NTEXT); Create.Column("tourData").OnTable("umbracoUser").AsCustom(textType).Nullable(); } }
public override void Up() { // don't execute if the column is already there var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("umbracoServer") && x.ColumnName.InvariantEquals("isMaster")) == false) { Create.Column("isMaster").OnTable("umbracoServer").AsBoolean().NotNullable().WithDefaultValue(0); } EnsureLockObject(Constants.Locks.Servers, "0AF5E610-A310-4B6F-925F-E928D5416AF7", "LOCK: Servers"); }
/// <remarks> /// The conditionals are useful to enable the same migration to be used in multiple /// migration paths x.x -> 8.18 and x.x -> 9.x /// </remarks> public override void Migrate() { var tables = SqlSyntax.GetTablesInSchema(Context.Database); if (!tables.InvariantContains(ContentVersionCleanupPolicyDto.TableName)) { Create.Table <ContentVersionCleanupPolicyDto>().Do(); } var columns = SqlSyntax.GetColumnsInSchema(Context.Database); AddColumnIfNotExists <ContentVersionDto>(columns, "preventCleanup"); }
/// <remarks> /// The conditionals are useful to enable the same migration to be used in multiple /// migration paths x.x -> 8.18 and x.x -> 9.x /// </remarks> protected override void Migrate() { IEnumerable <string> tables = SqlSyntax.GetTablesInSchema(Context.Database); if (!tables.InvariantContains(ContentVersionCleanupPolicyDto.TableName)) { Create.Table <ContentVersionCleanupPolicyDto>().Do(); } IEnumerable <ColumnInfo> columns = SqlSyntax.GetColumnsInSchema(Context.Database); AddColumnIfNotExists <ContentVersionDto>(columns, "preventCleanup"); }
/// <summary> /// </summary> /// <exception cref="NotImplementedException"></exception> public override void Up() { var database = ApplicationContext.Current.DatabaseContext.Database; var columns = SqlSyntax.GetColumnsInSchema(database).ToArray(); // 'isDefault' column if (columns.Any(x => x.TableName.InvariantEquals("merchProductVariant") && x.ColumnName.InvariantEquals("isDefault")) == false) { Logger.Info(typeof(AddIsDefaultColumn), "Adding IsDefault column to merchProductVariant table."); //// Add the new 'isDefaultChoice' column Create.Column("isDefault").OnTable("merchProductVariant").AsBoolean().WithDefaultValue(false); } }
public override void Up() { //Don't exeucte if the column is already there var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("umbracoCacheInstruction") && x.ColumnName.InvariantEquals("instructionCount")) == false) { Create.Column("instructionCount") .OnTable("umbracoCacheInstruction") .AsInt32() .WithDefaultValue(1) .NotNullable(); } }
public override void Up() { Logger.Info <AddColumns>("1.1.0: Running Migration"); var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); // as this table is created based on the object if someone directly installs // v1.1 then the first migration will have already created this column // so you need to confirm it isn't already there... if (columns.Any(x => x.TableName.InvariantEquals("SomeDataTable") && x.ColumnName.InvariantEquals("ExtraData")) == false) { Create.Column("ExtraData").OnTable("SomeDataTable").AsString(64).Nullable(); } }
public override void Up() { var columns = SqlSyntax.GetColumnsInSchema(Context.Database).ToArray(); if (columns.Any(x => x.TableName.InvariantEquals("umbracoRelationType") && x.ColumnName.InvariantEquals("typeUniqueId")) == false) { Create.Column("typeUniqueId").OnTable("umbracoRelationType").AsGuid().Nullable(); Execute.Code(UpdateRelationTypeGuids); Alter.Table("umbracoRelationType").AlterColumn("typeUniqueId").AsGuid().NotNullable(); Create.Index("IX_umbracoRelationType_UniqueId").OnTable("umbracoRelationType").OnColumn("typeUniqueId") .Ascending() .WithOptions().NonClustered() .WithOptions().Unique(); } }