From 87a6bffbf31bd066523c63cb7b52e73b6581151b Mon Sep 17 00:00:00 2001 From: trembon Date: Mon, 16 Dec 2024 18:25:07 +0100 Subject: [PATCH] remove log context and merge with default --- HomeAutomation.Core/Logging/DatabaseLogger.cs | 4 +- .../ScheduledJobs/CleanupLogScheduleJob.cs | 5 +- .../Services/EmailReceiveService.cs | 4 +- .../Contexts/DefaultContext.cs | 4 + .../Contexts/LogContext.cs | 23 --- .../Extensions/IHostExtensions.cs | 3 +- .../IServiceCollectionExtensions.cs | 7 +- .../20241216172408_mergeWithLog.Designer.cs | 182 ++++++++++++++++++ .../20241216172408_mergeWithLog.cs} | 23 ++- .../DefaultContextModelSnapshot.cs | 51 ++++- .../20240604091127_postgres_init.Designer.cs | 93 --------- .../LogMigrations/LogContextModelSnapshot.cs | 90 --------- HomeAutomation.Database/readme.md | 6 - .../Components/Pages/Logs/Logs.razor | 2 +- .../Components/Pages/Logs/SmtpLogs.razor | 2 +- HomeAutomation/Program.cs | 1 - HomeAutomation/appsettings.json | 1 - 17 files changed, 261 insertions(+), 240 deletions(-) delete mode 100644 HomeAutomation.Database/Contexts/LogContext.cs create mode 100644 HomeAutomation.Database/Migrations/DefaultMigrations/20241216172408_mergeWithLog.Designer.cs rename HomeAutomation.Database/Migrations/{LogMigrations/20240604091127_postgres_init.cs => DefaultMigrations/20241216172408_mergeWithLog.cs} (70%) delete mode 100644 HomeAutomation.Database/Migrations/LogMigrations/20240604091127_postgres_init.Designer.cs delete mode 100644 HomeAutomation.Database/Migrations/LogMigrations/LogContextModelSnapshot.cs diff --git a/HomeAutomation.Core/Logging/DatabaseLogger.cs b/HomeAutomation.Core/Logging/DatabaseLogger.cs index 892c0a5..49e2940 100644 --- a/HomeAutomation.Core/Logging/DatabaseLogger.cs +++ b/HomeAutomation.Core/Logging/DatabaseLogger.cs @@ -33,7 +33,7 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except try { - using LogContext db = serviceScope.ServiceProvider.GetRequiredService(); + using DefaultContext db = serviceScope.ServiceProvider.GetRequiredService(); using IDbContextTransaction transaction = db.Database.BeginTransaction(); LogRow row = new LogRow @@ -65,4 +65,4 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except } } } -} +} \ No newline at end of file diff --git a/HomeAutomation.Core/ScheduledJobs/CleanupLogScheduleJob.cs b/HomeAutomation.Core/ScheduledJobs/CleanupLogScheduleJob.cs index 80cbffc..9c08f73 100644 --- a/HomeAutomation.Core/ScheduledJobs/CleanupLogScheduleJob.cs +++ b/HomeAutomation.Core/ScheduledJobs/CleanupLogScheduleJob.cs @@ -5,7 +5,7 @@ namespace HomeAutomation.ScheduledJobs; -public class CleanupLogScheduleJob(LogContext logContext, ILogger logger) : IScheduledJob +public class CleanupLogScheduleJob(DefaultContext logContext, ILogger logger) : IScheduledJob { public async Task Execute(DateTime currentExecution, DateTime? lastExecution, CancellationToken cancellationToken) { @@ -14,10 +14,9 @@ public async Task Execute(DateTime currentExecution, DateTime? lastExecution, Ca DateTime loglimit = DateTime.UtcNow.AddDays(-7); // TODO: place in configuration? _ = await logContext.Rows.Where(x => loglimit > x.Timestamp).ExecuteDeleteAsync(); - DateTime maillimit = DateTime.UtcNow.AddDays(-3); // TODO: place in configuration? _ = await logContext.MailMessages.Where(x => maillimit > x.Timestamp).ExecuteDeleteAsync(); logger.LogInformation("Schedule.Cleanup :: done"); } -} +} \ No newline at end of file diff --git a/HomeAutomation.Core/Services/EmailReceiveService.cs b/HomeAutomation.Core/Services/EmailReceiveService.cs index 1c92894..1a119de 100644 --- a/HomeAutomation.Core/Services/EmailReceiveService.cs +++ b/HomeAutomation.Core/Services/EmailReceiveService.cs @@ -86,10 +86,10 @@ private async Task SaveToEml(IServiceScope scope, string messageId, byte[] emlDa EmlData = emlData }; - var context = scope.ServiceProvider.GetService(); + var context = scope.ServiceProvider.GetService(); context.Add(mailMessage); await context.SaveChangesAsync(); } } -} +} \ No newline at end of file diff --git a/HomeAutomation.Database/Contexts/DefaultContext.cs b/HomeAutomation.Database/Contexts/DefaultContext.cs index 98ed1f7..bc1373a 100644 --- a/HomeAutomation.Database/Contexts/DefaultContext.cs +++ b/HomeAutomation.Database/Contexts/DefaultContext.cs @@ -11,6 +11,10 @@ public class DefaultContext(DbContextOptions options) : DbContex public DbSet WeatherForecast { get; set; } + public DbSet Rows { get; set; } + + public DbSet MailMessages { get; set; } + protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); diff --git a/HomeAutomation.Database/Contexts/LogContext.cs b/HomeAutomation.Database/Contexts/LogContext.cs deleted file mode 100644 index b23ec28..0000000 --- a/HomeAutomation.Database/Contexts/LogContext.cs +++ /dev/null @@ -1,23 +0,0 @@ -using HomeAutomation.Database.Entities; -using Microsoft.EntityFrameworkCore; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace HomeAutomation.Database.Contexts; - -public class LogContext(DbContextOptions options) : DbContext(options) -{ - public DbSet Rows { get; set; } - - public DbSet MailMessages { get; set; } - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - base.OnModelCreating(modelBuilder); - - modelBuilder.Entity().Property(sp => sp.Timestamp).HasConversion(v => v.ToUniversalTime(), v => DateTime.SpecifyKind(v, DateTimeKind.Utc).ToLocalTime()); - modelBuilder.Entity().Property(sp => sp.Timestamp).HasConversion(v => v.ToUniversalTime(), v => DateTime.SpecifyKind(v, DateTimeKind.Utc).ToLocalTime()); - } -} diff --git a/HomeAutomation.Database/Extensions/IHostExtensions.cs b/HomeAutomation.Database/Extensions/IHostExtensions.cs index 1abd1cf..c158314 100644 --- a/HomeAutomation.Database/Extensions/IHostExtensions.cs +++ b/HomeAutomation.Database/Extensions/IHostExtensions.cs @@ -10,7 +10,6 @@ public static class IHostExtensions public static void ApplyDatabaseMigrations(this IHost host) { host.ApplyDatabaseMigration(); - host.ApplyDatabaseMigration(); } private static void ApplyDatabaseMigration(this IHost host) where TContext : DbContext @@ -19,4 +18,4 @@ private static void ApplyDatabaseMigration(this IHost host) where TCon var context = scope.ServiceProvider.GetRequiredService(); context.Database.Migrate(); } -} +} \ No newline at end of file diff --git a/HomeAutomation.Database/Extensions/IServiceCollectionExtensions.cs b/HomeAutomation.Database/Extensions/IServiceCollectionExtensions.cs index c666a1b..a39c645 100644 --- a/HomeAutomation.Database/Extensions/IServiceCollectionExtensions.cs +++ b/HomeAutomation.Database/Extensions/IServiceCollectionExtensions.cs @@ -17,14 +17,9 @@ public static void AddDefaultDatabaseContext(this IServiceCollection services, s services.AddDatabaseContext(postgressConnectionString); } - public static void AddLoggingDatabaseContext(this IServiceCollection services, string postgressConnectionString) - { - services.AddDatabaseContext(postgressConnectionString); - } - private static void AddDatabaseContext(this IServiceCollection services, string postgressConnectionString) where TContext : DbContext { string assemblyName = Assembly.GetExecutingAssembly().GetName().Name!; services.AddDbContext(options => options.UseNpgsql(postgressConnectionString, x => x.MigrationsAssembly(assemblyName)), ServiceLifetime.Transient); } -} +} \ No newline at end of file diff --git a/HomeAutomation.Database/Migrations/DefaultMigrations/20241216172408_mergeWithLog.Designer.cs b/HomeAutomation.Database/Migrations/DefaultMigrations/20241216172408_mergeWithLog.Designer.cs new file mode 100644 index 0000000..abc2d00 --- /dev/null +++ b/HomeAutomation.Database/Migrations/DefaultMigrations/20241216172408_mergeWithLog.Designer.cs @@ -0,0 +1,182 @@ +// +using System; +using HomeAutomation.Database.Contexts; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace HomeAutomation.Database.Migrations.DefaultMigrations +{ + [DbContext(typeof(DefaultContext))] + [Migration("20241216172408_mergeWithLog")] + partial class mergeWithLog + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.7") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("HomeAutomation.Database.Entities.LogRow", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ID")); + + b.Property("Category") + .IsRequired() + .HasColumnType("text"); + + b.Property("EventID") + .HasColumnType("integer"); + + b.Property("Exception") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Message") + .IsRequired() + .HasColumnType("text"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ID"); + + b.ToTable("Rows"); + }); + + modelBuilder.Entity("HomeAutomation.Database.Entities.MailMessage", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ID")); + + b.Property("DeviceSource") + .HasColumnType("text"); + + b.Property("DeviceSourceID") + .HasColumnType("text"); + + b.Property("EmlData") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("MessageID") + .IsRequired() + .HasColumnType("text"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("ID"); + + b.ToTable("MailMessages"); + }); + + modelBuilder.Entity("HomeAutomation.Database.Entities.SensorValue", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ID")); + + b.Property("Source") + .HasColumnType("integer"); + + b.Property("SourceID") + .IsRequired() + .HasColumnType("text"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Type") + .HasColumnType("integer"); + + b.Property("Value") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("ID"); + + b.ToTable("SensorValues"); + }); + + modelBuilder.Entity("HomeAutomation.Database.Entities.SunData", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ID")); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("Sunrise") + .HasColumnType("time without time zone"); + + b.Property("Sunset") + .HasColumnType("time without time zone"); + + b.HasKey("ID"); + + b.HasIndex("Date") + .IsUnique(); + + b.ToTable("SunData"); + }); + + modelBuilder.Entity("HomeAutomation.Database.Entities.WeatherForecast", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ID")); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("Rain") + .HasColumnType("double precision"); + + b.Property("SymbolID") + .HasColumnType("text"); + + b.Property("Temperature") + .HasColumnType("double precision"); + + b.Property("WindDirection") + .HasColumnType("text"); + + b.Property("WindSpeed") + .HasColumnType("double precision"); + + b.HasKey("ID"); + + b.ToTable("WeatherForecast"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/HomeAutomation.Database/Migrations/LogMigrations/20240604091127_postgres_init.cs b/HomeAutomation.Database/Migrations/DefaultMigrations/20241216172408_mergeWithLog.cs similarity index 70% rename from HomeAutomation.Database/Migrations/LogMigrations/20240604091127_postgres_init.cs rename to HomeAutomation.Database/Migrations/DefaultMigrations/20241216172408_mergeWithLog.cs index 7ded60c..1603621 100644 --- a/HomeAutomation.Database/Migrations/LogMigrations/20240604091127_postgres_init.cs +++ b/HomeAutomation.Database/Migrations/DefaultMigrations/20241216172408_mergeWithLog.cs @@ -4,14 +4,17 @@ #nullable disable -namespace HomeAutomation.Database.Migrations.LogMigrations +namespace HomeAutomation.Database.Migrations.DefaultMigrations { /// - public partial class postgres_init : Migration + public partial class mergeWithLog : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.DropTable( + name: "PhoneCalls"); + migrationBuilder.CreateTable( name: "MailMessages", columns: table => new @@ -56,6 +59,22 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "Rows"); + + migrationBuilder.CreateTable( + name: "PhoneCalls", + columns: table => new + { + ID = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Length = table.Column(type: "interval", nullable: false), + Number = table.Column(type: "text", nullable: false), + Timestamp = table.Column(type: "timestamp with time zone", nullable: false), + Type = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PhoneCalls", x => x.ID); + }); } } } diff --git a/HomeAutomation.Database/Migrations/DefaultMigrations/DefaultContextModelSnapshot.cs b/HomeAutomation.Database/Migrations/DefaultMigrations/DefaultContextModelSnapshot.cs index 9bdac5e..eff5891 100644 --- a/HomeAutomation.Database/Migrations/DefaultMigrations/DefaultContextModelSnapshot.cs +++ b/HomeAutomation.Database/Migrations/DefaultMigrations/DefaultContextModelSnapshot.cs @@ -17,12 +17,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") + .HasAnnotation("ProductVersion", "8.0.7") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - modelBuilder.Entity("HomeAutomation.Database.Entities.PhoneCall", b => + modelBuilder.Entity("HomeAutomation.Database.Entities.LogRow", b => { b.Property("ID") .ValueGeneratedOnAdd() @@ -30,22 +30,59 @@ protected override void BuildModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ID")); - b.Property("Length") - .HasColumnType("interval"); + b.Property("Category") + .IsRequired() + .HasColumnType("text"); + + b.Property("EventID") + .HasColumnType("integer"); + + b.Property("Exception") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); - b.Property("Number") + b.Property("Message") .IsRequired() .HasColumnType("text"); b.Property("Timestamp") .HasColumnType("timestamp with time zone"); - b.Property("Type") + b.HasKey("ID"); + + b.ToTable("Rows"); + }); + + modelBuilder.Entity("HomeAutomation.Database.Entities.MailMessage", b => + { + b.Property("ID") + .ValueGeneratedOnAdd() .HasColumnType("integer"); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ID")); + + b.Property("DeviceSource") + .HasColumnType("text"); + + b.Property("DeviceSourceID") + .HasColumnType("text"); + + b.Property("EmlData") + .IsRequired() + .HasColumnType("bytea"); + + b.Property("MessageID") + .IsRequired() + .HasColumnType("text"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + b.HasKey("ID"); - b.ToTable("PhoneCalls"); + b.ToTable("MailMessages"); }); modelBuilder.Entity("HomeAutomation.Database.Entities.SensorValue", b => diff --git a/HomeAutomation.Database/Migrations/LogMigrations/20240604091127_postgres_init.Designer.cs b/HomeAutomation.Database/Migrations/LogMigrations/20240604091127_postgres_init.Designer.cs deleted file mode 100644 index f05c198..0000000 --- a/HomeAutomation.Database/Migrations/LogMigrations/20240604091127_postgres_init.Designer.cs +++ /dev/null @@ -1,93 +0,0 @@ -// -using System; -using HomeAutomation.Database.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace HomeAutomation.Database.Migrations.LogMigrations -{ - [DbContext(typeof(LogContext))] - [Migration("20240604091127_postgres_init")] - partial class postgres_init - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("HomeAutomation.Database.Entities.LogRow", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ID")); - - b.Property("Category") - .IsRequired() - .HasColumnType("text"); - - b.Property("EventID") - .HasColumnType("integer"); - - b.Property("Exception") - .HasColumnType("text"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Message") - .IsRequired() - .HasColumnType("text"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ID"); - - b.ToTable("Rows"); - }); - - modelBuilder.Entity("HomeAutomation.Database.Entities.MailMessage", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ID")); - - b.Property("DeviceSource") - .HasColumnType("text"); - - b.Property("DeviceSourceID") - .HasColumnType("text"); - - b.Property("EmlData") - .IsRequired() - .HasColumnType("bytea"); - - b.Property("MessageID") - .IsRequired() - .HasColumnType("text"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ID"); - - b.ToTable("MailMessages"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/HomeAutomation.Database/Migrations/LogMigrations/LogContextModelSnapshot.cs b/HomeAutomation.Database/Migrations/LogMigrations/LogContextModelSnapshot.cs deleted file mode 100644 index daaafe7..0000000 --- a/HomeAutomation.Database/Migrations/LogMigrations/LogContextModelSnapshot.cs +++ /dev/null @@ -1,90 +0,0 @@ -// -using System; -using HomeAutomation.Database.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace HomeAutomation.Database.Migrations.LogMigrations -{ - [DbContext(typeof(LogContext))] - partial class LogContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.6") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("HomeAutomation.Database.Entities.LogRow", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ID")); - - b.Property("Category") - .IsRequired() - .HasColumnType("text"); - - b.Property("EventID") - .HasColumnType("integer"); - - b.Property("Exception") - .HasColumnType("text"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Message") - .IsRequired() - .HasColumnType("text"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ID"); - - b.ToTable("Rows"); - }); - - modelBuilder.Entity("HomeAutomation.Database.Entities.MailMessage", b => - { - b.Property("ID") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("ID")); - - b.Property("DeviceSource") - .HasColumnType("text"); - - b.Property("DeviceSourceID") - .HasColumnType("text"); - - b.Property("EmlData") - .IsRequired() - .HasColumnType("bytea"); - - b.Property("MessageID") - .IsRequired() - .HasColumnType("text"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("ID"); - - b.ToTable("MailMessages"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/HomeAutomation.Database/readme.md b/HomeAutomation.Database/readme.md index feb91bc..6273736 100644 --- a/HomeAutomation.Database/readme.md +++ b/HomeAutomation.Database/readme.md @@ -4,10 +4,4 @@ ``` dotnet ef migrations add --context DefaultContext --project HomeAutomation.Database --startup-project HomeAutomation --output-dir Migrations/DefaultMigrations --prefix-output -``` - -## Log context - -``` -dotnet ef migrations add --context LogContext --project HomeAutomation.Database --startup-project HomeAutomation --output-dir Migrations/LogMigrations --prefix-output ``` \ No newline at end of file diff --git a/HomeAutomation/Components/Pages/Logs/Logs.razor b/HomeAutomation/Components/Pages/Logs/Logs.razor index 834b9fa..053f058 100644 --- a/HomeAutomation/Components/Pages/Logs/Logs.razor +++ b/HomeAutomation/Components/Pages/Logs/Logs.razor @@ -1,7 +1,7 @@ @page "/logs" @using HomeAutomation.Database.Contexts @using Microsoft.EntityFrameworkCore -@inject LogContext context +@inject DefaultContext context Logs - Default diff --git a/HomeAutomation/Components/Pages/Logs/SmtpLogs.razor b/HomeAutomation/Components/Pages/Logs/SmtpLogs.razor index cf96819..e034011 100644 --- a/HomeAutomation/Components/Pages/Logs/SmtpLogs.razor +++ b/HomeAutomation/Components/Pages/Logs/SmtpLogs.razor @@ -1,7 +1,7 @@ @page "/logs/smtp" @using HomeAutomation.Database.Contexts @using Microsoft.EntityFrameworkCore -@inject LogContext context +@inject DefaultContext context Logs - SMTP diff --git a/HomeAutomation/Program.cs b/HomeAutomation/Program.cs index 69a4197..42a6d45 100644 --- a/HomeAutomation/Program.cs +++ b/HomeAutomation/Program.cs @@ -23,7 +23,6 @@ builder.Services.AddHttpClient(); builder.Services.AddDefaultDatabaseContext(builder.Configuration.GetConnectionString("Default")!); -builder.Services.AddLoggingDatabaseContext(builder.Configuration.GetConnectionString("Logging")!); builder.Logging.Services.TryAddEnumerable(ServiceDescriptor.Singleton()); if (!builder.Environment.IsDevelopment()) diff --git a/HomeAutomation/appsettings.json b/HomeAutomation/appsettings.json index 0db8d48..ccc39dd 100644 --- a/HomeAutomation/appsettings.json +++ b/HomeAutomation/appsettings.json @@ -1,7 +1,6 @@ { "ConnectionStrings": { "Default": "postgres connection string", - "Logging": "postgres connection string", "Json": "database.json" }, "ScheduledJobs": {