using System; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; using Oqtane.Enums; using Oqtane.Models; using Oqtane.Modules.HtmlText.Repository; using Oqtane.Repository; namespace Oqtane.Modules { public class MigratableModuleBase { public bool Migrate(DBContextBase dbContext, Tenant tenant, MigrationType migrationType) { var result = true; using (dbContext) { try { var migrator = dbContext.GetService(); if (migrationType == MigrationType.Down) { migrator.Migrate(Migration.InitialDatabase); } else { migrator.Migrate(); } } catch (Exception e) { Console.WriteLine(e); result = false; } } return result; } } }