Skip to content

Commit

Permalink
93: Fix for SQLite migration not working (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickdemooij9 authored Jul 8, 2022
1 parent 816fb24 commit 5ba2381
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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<SitemapPageTypeEntity>().Do();
Database.InsertBulk(Database.Fetch<SitemapPageTypeEntity>(Sql()
.SelectAll()
.From("old_SeoToolkitSitemapPageType")));
}
else
{
Alter.Table("SeoToolkitSitemapPageType").AlterColumn("ChangeFrequency").AsString().Nullable().Do();
}
Expand Down

0 comments on commit 5ba2381

Please sign in to comment.