Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

185: Fix migration for SQLite #190

Merged
merged 1 commit into from
May 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);");
}
}
}
}