refactored IUpgradeable to use the migration attribute approach

This commit is contained in:
Shaun Walker
2022-04-02 09:19:30 -04:00
parent 2ba1a95c8d
commit 268e0e72a3
5 changed files with 87 additions and 79 deletions

View File

@ -1,41 +1,14 @@
using Oqtane.Models;
using Oqtane.Documentation;
namespace Oqtane.Infrastructure
{
[PrivateApi("Mark Site-Template classes as private, since it's not very useful in the public docs")]
public class ExampleUpgrade : IUpgradeable
[SiteUpgrade("localhost:44357", "01.00.00")]
public class ExampleUpgrade : ISiteUpgrade
{
string IUpgradeable.GetVersions(Alias alias)
bool ISiteUpgrade.Upgrade(Site site, Alias alias)
{
var versions = "";
switch (alias.Name)
{
case "localhost:44357":
// return the comma delimited list of official release versions for the specific site
versions = "1.0.0";
break;
}
return versions;
}
bool IUpgradeable.Upgrade(Alias alias, string version)
{
bool success = true;
switch (alias.Name)
{
case "localhost:44357":
// the version cases should match the list of versions returned above
switch (version)
{
case "1.0.0":
// execute some version-specific upgrade logic for the site here such as adding pages, modules, content, etc...
success = true;
break;
}
break;
}
return success;
// execute some version-specific upgrade logic for the site here such as adding pages, modules, content, etc...
return true;
}
}
}