Skip to content

Commit

Permalink
185: Fix migration for SQLite (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdemooij9 committed Jun 1, 2023
1 parent 4c261fd commit c0465ae
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Umbraco.Cms.Infrastructure.Migrations;
using SeoToolkit.Umbraco.MetaFields.Core.Models.SeoSettings.Database;
using Umbraco.Cms.Infrastructure.Migrations;
using Umbraco.Extensions;

namespace SeoToolkit.Umbraco.MetaFields.Core.Migrations
{
Expand All @@ -10,7 +12,19 @@ public MetaFieldsValueTextMigration(IMigrationContext context) : base(context)

protected override void Migrate()
{
Database.Execute($"ALTER TABLE SeoToolkitMetaFieldsValue ALTER COLUMN UserValue nvarchar(max);");
if (DatabaseType == NPoco.DatabaseType.SQLite)
{
//SQLite doesn't support normal altering of columns. https://github.com/umbraco/Umbraco-CMS/issues/12676
Database.Execute("ALTER TABLE SeoToolkitMetaFieldsValue RENAME TO old_SeoToolkitMetaFieldsValue;");
Create.Table<MetaFieldsValueEntity>().Do();
Database.InsertBulk(Database.Fetch<MetaFieldsValueEntity>(Sql()
.SelectAll()
.From("old_SeoToolkitMetaFieldsValue")));
}
else
{
Database.Execute($"ALTER TABLE SeoToolkitMetaFieldsValue ALTER COLUMN UserValue nvarchar(max);");
}
}
}
}

0 comments on commit c0465ae

Please sign in to comment.