@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZero
|
||||
{
|
||||
[Migration("7.3.0", 17, GlobalSettings.UmbracoMigrationName)]
|
||||
public class AddServerRegistrationColumnsAndLock : MigrationBase
|
||||
{
|
||||
public AddServerRegistrationColumnsAndLock(ISqlSyntaxProvider sqlSyntax, ILogger logger)
|
||||
: base(sqlSyntax, logger)
|
||||
{ }
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// wrap in a transaction so that everything runs on the same connection
|
||||
// and the IDENTITY_INSERT stuff is effective for all inserts.
|
||||
using (var tr = Context.Database.GetTransaction())
|
||||
{
|
||||
// turn on identity insert if db provider is not mysql
|
||||
if (SqlSyntax.SupportsIdentityInsert())
|
||||
Context.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
|
||||
InsertLockObject(Constants.System.ServersLock, "0AF5E610-A310-4B6F-925F-E928D5416AF7", "LOCK: Servers");
|
||||
|
||||
// turn off identity insert if db provider is not mysql
|
||||
if (SqlSyntax.SupportsIdentityInsert())
|
||||
Context.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF", SqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
|
||||
tr.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
// not implemented
|
||||
}
|
||||
|
||||
private void InsertLockObject(int id, string uniqueId, string text)
|
||||
{
|
||||
var exists = Context.Database.Exists<NodeDto>(id);
|
||||
if (exists) return;
|
||||
|
||||
Context.Database.Insert("umbracoNode", "id", false, new NodeDto
|
||||
{
|
||||
NodeId = id,
|
||||
Trashed = false,
|
||||
ParentId = -1,
|
||||
UserId = 0,
|
||||
Level = 1,
|
||||
Path = "-1," + id,
|
||||
SortOrder = 0,
|
||||
UniqueId = new Guid(uniqueId),
|
||||
Text = text,
|
||||
NodeObjectType = new Guid(Constants.ObjectTypes.LockObject),
|
||||
CreateDate = DateTime.Now
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Core.Persistence.Migrations.Upgrades.TargetVersionSevenThreeZero
|
||||
{
|
||||
[Migration("7.3.0", 17, GlobalSettings.UmbracoMigrationName)]
|
||||
public class AddServerRegistrationIsMasterColumn : MigrationBase
|
||||
{
|
||||
public AddServerRegistrationIsMasterColumn(ISqlSyntaxProvider sqlSyntax, ILogger logger)
|
||||
: base(sqlSyntax, logger)
|
||||
{ }
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
// not implemented
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -406,7 +406,7 @@
|
||||
<Compile Include="Persistence\Mappers\MigrationEntryMapper.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddExternalLoginsTable.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddForeignKeysForLanguageAndDictionaryTables.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddServerRegistrationIsMasterColumn.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddServerRegistrationColumnsAndLock.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddMigrationTable.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddPublicAccessTables.cs" />
|
||||
<Compile Include="Persistence\Migrations\Upgrades\TargetVersionSevenThreeZero\AddUniqueIdPropertyTypeColumn.cs" />
|
||||
|
||||
@@ -1,63 +0,0 @@
|
||||
using System;
|
||||
using Semver;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Events;
|
||||
using Umbraco.Core.Models.Rdbms;
|
||||
using Umbraco.Core.Persistence;
|
||||
using Umbraco.Core.Persistence.Migrations;
|
||||
using Umbraco.Core.Persistence.SqlSyntax;
|
||||
|
||||
namespace Umbraco.Web.Strategies.Migrations
|
||||
{
|
||||
public class EnsureServerLockNodeExists : MigrationStartupHander
|
||||
{
|
||||
protected override void AfterMigration(MigrationRunner sender, MigrationEventArgs e)
|
||||
{
|
||||
var target = new SemVersion(7, 3);
|
||||
|
||||
if (e.ConfiguredSemVersion > target)
|
||||
return;
|
||||
|
||||
var context = e.MigrationContext;
|
||||
var sqlSyntax = SqlSyntaxContext.SqlSyntaxProvider;
|
||||
|
||||
// wrap in a transaction so that everything runs on the same connection
|
||||
// and the IDENTITY_INSERT stuff is effective for all inserts.
|
||||
using (var tr = context.Database.GetTransaction())
|
||||
{
|
||||
// turn on identity insert if db provider is not mysql
|
||||
if (sqlSyntax.SupportsIdentityInsert())
|
||||
context.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON", sqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
|
||||
EnsureLockNode(context, Constants.System.ServersLock, "0AF5E610-A310-4B6F-925F-E928D5416AF7", "LOCK: Servers");
|
||||
|
||||
// turn off identity insert if db provider is not mysql
|
||||
if (sqlSyntax.SupportsIdentityInsert())
|
||||
context.Database.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF", sqlSyntax.GetQuotedTableName("umbracoNode"))));
|
||||
|
||||
tr.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
private static void EnsureLockNode(IMigrationContext context, int id, string uniqueId, string text)
|
||||
{
|
||||
var exists = context.Database.Exists<NodeDto>(id);
|
||||
if (exists) return;
|
||||
|
||||
context.Database.Insert("umbracoNode", "id", false, new NodeDto
|
||||
{
|
||||
NodeId = id,
|
||||
Trashed = false,
|
||||
ParentId = -1,
|
||||
UserId = 0,
|
||||
Level = 1,
|
||||
Path = "-1," + id,
|
||||
SortOrder = 0,
|
||||
UniqueId = new Guid(uniqueId),
|
||||
Text = text,
|
||||
NodeObjectType = new Guid(Constants.ObjectTypes.LockObject),
|
||||
CreateDate = DateTime.Now
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -313,7 +313,6 @@
|
||||
<Compile Include="Media\EmbedProviders\OEmbedResponse.cs" />
|
||||
<Compile Include="Media\EmbedProviders\OEmbedPhoto.cs" />
|
||||
<Compile Include="Security\Identity\IUmbracoBackOfficeTwoFactorOptions.cs" />
|
||||
<Compile Include="Strategies\Migrations\EnsureServerLockNodeExists.cs" />
|
||||
<Compile Include="UmbracoDefaultOwinStartup.cs" />
|
||||
<Compile Include="IUmbracoContextAccessor.cs" />
|
||||
<Compile Include="Models\ContentEditing\Relation.cs" />
|
||||
|
||||
Reference in New Issue
Block a user