-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/v13/dev' into v14/dev
- Loading branch information
Showing
5 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Umbraco.Infrastructure/Migrations/Upgrade/V_13_5_0/ChangeRedirectUrlToNvarcharMax.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Linq.Expressions; | ||
using System.Text; | ||
using NPoco; | ||
using Umbraco.Cms.Core; | ||
using Umbraco.Cms.Infrastructure.Migrations.Expressions.Create.Column; | ||
using Umbraco.Cms.Infrastructure.Persistence; | ||
using Umbraco.Cms.Infrastructure.Persistence.Dtos; | ||
|
||
namespace Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_13_5_0; | ||
|
||
public class ChangeRedirectUrlToNvarcharMax : MigrationBase | ||
{ | ||
public ChangeRedirectUrlToNvarcharMax(IMigrationContext context) : base(context) | ||
{ | ||
} | ||
|
||
protected override void Migrate() | ||
{ | ||
// We don't need to run this migration for SQLite, since ntext is not a thing there, text is just text. | ||
if (DatabaseType == DatabaseType.SQLite) | ||
{ | ||
return; | ||
} | ||
|
||
string tableName = RedirectUrlDto.TableName; | ||
string colName = "url"; | ||
|
||
// Determine the current datatype of the column within the database | ||
string colDataType = Database.ExecuteScalar<string>($"SELECT TOP(1) CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS" + | ||
$" WHERE TABLE_NAME = '{tableName}' AND COLUMN_NAME = '{colName}'"); | ||
|
||
// 255 is the old length, -1 indicate MAX length | ||
if (colDataType == "255") | ||
{ | ||
// Upgrade to MAX length | ||
Database.Execute($"Drop Index IX_umbracoRedirectUrl_culture_hash on {Constants.DatabaseSchema.Tables.RedirectUrl}"); | ||
Database.Execute($"ALTER TABLE {tableName} ALTER COLUMN {colName} nvarchar(MAX) NOT NULL"); | ||
Database.Execute($"CREATE INDEX IX_umbracoRedirectUrl_culture_hash ON {Constants.DatabaseSchema.Tables.RedirectUrl} (urlHash, contentKey, culture, createDateUtc)"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule Umbraco.Web.UI.Client
deleted from
f30f89