Skip to content

Commit

Permalink
Merge branch 'release/13.5' into v13/dev and version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
Migaroez committed Sep 12, 2024
2 parents a74d963 + a6c5581 commit b237285
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,6 @@ protected virtual void DefinePlan()
To<V_13_0_0.ChangeWebhookUrlColumnsToNvarcharMax>("{21C42760-5109-4C03-AB4F-7EA53577D1F5}");
To<V_13_0_0.AddExceptionOccured>("{6158F3A3-4902-4201-835E-1ED7F810B2D8}");
To<V_13_3_0.AlignUpgradedDatabase>("{985AF2BA-69D3-4DBA-95E0-AD3FA7459FA7}");
To<V_13_5_0.ChangeRedirectUrlToNvarcharMax>("{CC47C751-A81B-489A-A2BC-0240245DB687}");
}
}
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)");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ internal class RedirectUrlDto

[Column("url")]
[NullSetting(NullSetting = NullSettings.NotNull)]
[SpecialDbType(SpecialDbTypes.NVARCHARMAX)]
public string Url { get; set; } = null!;

[Column("culture")]
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
"version": "13.5.0-rc",
"version": "13.6.0-rc",
"assemblyVersion": {
"precision": "build"
},
Expand Down

0 comments on commit b237285

Please sign in to comment.