db changes and build pipeline
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2022-07-15 12:21:37 -04:00
parent 5337e7ccb8
commit e6d6b629db
30 changed files with 1332 additions and 132 deletions

View File

@@ -0,0 +1,17 @@
using Microsoft.EntityFrameworkCore;
namespace WebNovelPortalAPI.Extensions;
public static class DBUpdateExtensions
{
public static void UpdateDatabase<T>(this IApplicationBuilder app) where T : DbContext
{
using var serviceScope = app.ApplicationServices.CreateScope();
using var context = serviceScope.ServiceProvider.GetService<T>();
if (context.Database.GetPendingMigrations().Any())
{
context.Database.Migrate();
}
}
}

View File

@@ -8,7 +8,7 @@ public static class ScraperExtensions
public static void AddScrapers(this IServiceCollection services)
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes().Where(t =>
t.IsClass && typeof(IScraper).IsAssignableFrom(t) && (t.Namespace?.Contains(nameof(Scrapers)) ?? false))
t.IsClass && typeof(IScraper).IsAssignableFrom(t) && !t.IsAbstract && (t.Namespace?.Contains(nameof(Scrapers)) ?? false))
.ToArray();
foreach (var t in types)
{