Fix a few things, the v8 way

This commit is contained in:
Stephan
2018-03-22 17:51:34 +01:00
parent 3a3d6239f0
commit 59bac5c2a6
4 changed files with 14 additions and 11 deletions

View File

@@ -64,7 +64,7 @@ namespace Umbraco.Core.Migrations.Upgrade
//
// when installing, the source state is empty, and the target state should be the final state.
Add(string.Empty, "{CA7DB949-3EF4-403D-8464-F9BA36A52E87}");
Add(string.Empty, "{7F0BF916-F64E-4B25-864A-170D6E6B68E5}");
// UPGRADE FROM 7
//
@@ -84,7 +84,8 @@ namespace Umbraco.Core.Migrations.Upgrade
.Chain<DataTypeMigration>("{8640C9E4-A1C0-4C59-99BB-609B4E604981}")
.Chain<TagsMigration>("{DD1B99AF-8106-4E00-BAC7-A43003EA07F8}")
.Chain<SuperZero>("{9DF05B77-11D1-475C-A00A-B656AF7E0908}")
.Chain<PropertyEditorsMigration>("{CA7DB949-3EF4-403D-8464-F9BA36A52E87}");;
.Chain<PropertyEditorsMigration>("{9E98CF10-3AE9-437B-AF54-8697D251A541}")
.Chain<LanguageColumns>("{7F0BF916-F64E-4B25-864A-170D6E6B68E5}");
// 7.8.1 = same as 7.8.0
From("{init-7.8.1}")
@@ -156,6 +157,7 @@ namespace Umbraco.Core.Migrations.Upgrade
Chain<TagsMigration>("{139F26D7-7E08-48E3-81D9-E50A21A72F67}");
Chain<SuperZero>("{CC1B1201-1328-443C-954A-E0BBB8CCC1B5}");
Chain<PropertyEditorsMigration>("{CA7DB949-3EF4-403D-8464-F9BA36A52E87}");
Chain<LanguageColumns>("{7F0BF916-F64E-4B25-864A-170D6E6B68E5}");
}
}
}

View File

@@ -1,15 +1,17 @@
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
using Umbraco.Core.Persistence.Dtos;
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
{
public class LanguageColumns : MigrationBase
{
protected LanguageColumns(IMigrationContext context) : base(context)
{
}
protected LanguageColumns(IMigrationContext context)
: base(context)
{ }
public override void Migrate()
{
Create.Column("isDefaultVariantLang").OnTable(Constants.DatabaseSchema.Tables.Language).AsBoolean().NotNullable();
Create.Column("mandatory").OnTable(Constants.DatabaseSchema.Tables.Language).AsBoolean().NotNullable();
AddColumn<LanguageDto>(Constants.DatabaseSchema.Tables.Language, "isDefaultVariantLang");
AddColumn<LanguageDto>(Constants.DatabaseSchema.Tables.Language, "mandatory");
}
}
}

View File

@@ -1,6 +1,5 @@
namespace Umbraco.Core.Migrations.Upgrade.V_8_0_0
{
public class SuperZero : MigrationBase
{
public SuperZero(IMigrationContext context)

View File

@@ -110,7 +110,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
if (entity.IsDefaultVariantLanguage)
{
//if this entity is flagged as the default, we need to set all others to false
Database.Execute($"UPDATE {SqlSyntax.GetQuotedColumnName(Constants.DatabaseSchema.Tables.Language)} SET {SqlSyntax.GetQuotedColumnName("isDefaultVariantLang")} = 0");
Database.Execute(Sql().Update<LanguageDto>(u => u.Set(x => x.IsDefaultVariantLanguage, false)));
//We need to clear the whole cache since all languages will be updated
IsolatedCache.ClearAllCache();
}
@@ -132,7 +132,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
if (entity.IsDefaultVariantLanguage)
{
//if this entity is flagged as the default, we need to set all others to false
Database.Execute($"UPDATE {SqlSyntax.GetQuotedColumnName(Constants.DatabaseSchema.Tables.Language)} SET {SqlSyntax.GetQuotedColumnName("isDefaultVariantLang")} = 0");
Database.Execute(Sql().Update<LanguageDto>(u => u.Set(x => x.IsDefaultVariantLanguage, false)));
//We need to clear the whole cache since all languages will be updated
IsolatedCache.ClearAllCache();
}