From 5ba2381fe91cc506ebfecf45fda82263f2c1e53e Mon Sep 17 00:00:00 2001 From: patrickdemooij9 Date: Fri, 8 Jul 2022 19:47:47 +0200 Subject: [PATCH] 93: Fix for SQLite migration not working (#94) --- .../SitemapChangeFrequencyOptionalMigration.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/SeoToolkit.Umbraco.Sitemap.Core/Migrations/SitemapChangeFrequencyOptionalMigration.cs b/src/SeoToolkit.Umbraco.Sitemap.Core/Migrations/SitemapChangeFrequencyOptionalMigration.cs index e8c8a2f3..2633ac6b 100644 --- a/src/SeoToolkit.Umbraco.Sitemap.Core/Migrations/SitemapChangeFrequencyOptionalMigration.cs +++ b/src/SeoToolkit.Umbraco.Sitemap.Core/Migrations/SitemapChangeFrequencyOptionalMigration.cs @@ -1,4 +1,7 @@ -using Umbraco.Cms.Infrastructure.Migrations; +using NPoco; +using SeoToolkit.Umbraco.Sitemap.Core.Models.Database; +using Umbraco.Cms.Infrastructure.Migrations; +using Umbraco.Extensions; namespace SeoToolkit.Umbraco.Sitemap.Core.Migrations { @@ -10,7 +13,18 @@ public SitemapChangeFrequencyOptionalMigration(IMigrationContext context) : base protected override void Migrate() { - if (ColumnExists("SeoToolkitSitemapPageType", "ChangeFrequency")) + if (!ColumnExists("SeoToolkitSitemapPageType", "ChangeFrequency")) return; + + if (DatabaseType == DatabaseType.SQLite) + { + //SQLite doesn't support normal altering of columns. https://github.com/umbraco/Umbraco-CMS/issues/12676 + Database.Execute("ALTER TABLE SeoToolkitSitemapPageType RENAME TO old_SeoToolkitSitemapPageType;"); + Create.Table().Do(); + Database.InsertBulk(Database.Fetch(Sql() + .SelectAll() + .From("old_SeoToolkitSitemapPageType"))); + } + else { Alter.Table("SeoToolkitSitemapPageType").AlterColumn("ChangeFrequency").AsString().Nullable().Do(); }