Change where the MigrationTable are to be created. Improve the update-databases.sh script
This commit is contained in:
@@ -6,10 +6,12 @@ public class ContentDbContext(
|
|||||||
DbContextOptions<ContentDbContext> options)
|
DbContextOptions<ContentDbContext> options)
|
||||||
: DbContext(options)
|
: DbContext(options)
|
||||||
{
|
{
|
||||||
|
public const string SchemaName = "Content";
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.HasDefaultSchema("Content");
|
modelBuilder.HasDefaultSchema("Content");
|
||||||
|
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.Entity<Content>()
|
.Entity<Content>()
|
||||||
.Property(c => c.CreatedAt)
|
.Property(c => c.CreatedAt)
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ public class MessagingDbContext(
|
|||||||
DbContextOptions<MessagingDbContext> options)
|
DbContextOptions<MessagingDbContext> options)
|
||||||
: DbContext(options)
|
: DbContext(options)
|
||||||
{
|
{
|
||||||
|
public const string SchemaName = "Messaging";
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
modelBuilder.HasDefaultSchema("Messaging");
|
modelBuilder.HasDefaultSchema(SchemaName);
|
||||||
|
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.Entity<Message>()
|
.Entity<Message>()
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ using Hutopy.Infrastructure.Data;
|
|||||||
using Hutopy.Infrastructure.Identity;
|
using Hutopy.Infrastructure.Identity;
|
||||||
using Hutopy.Web;
|
using Hutopy.Web;
|
||||||
using Hutopy.Web.Features.Contents;
|
using Hutopy.Web.Features.Contents;
|
||||||
|
using Hutopy.Web.Features.Contents.Data;
|
||||||
using Hutopy.Web.Features.Messages;
|
using Hutopy.Web.Features.Messages;
|
||||||
|
using Hutopy.Web.Features.Messages.Data;
|
||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using NSwag;
|
using NSwag;
|
||||||
@@ -73,17 +75,23 @@ builder.Services.AddOpenApiDocument((configure, sp) =>
|
|||||||
In = OpenApiSecurityApiKeyLocation.Header,
|
In = OpenApiSecurityApiKeyLocation.Header,
|
||||||
Description = "Type into the textbox: Bearer {your JWT token}.",
|
Description = "Type into the textbox: Bearer {your JWT token}.",
|
||||||
});
|
});
|
||||||
|
|
||||||
configure.OperationProcessors.Add(new AspNetCoreOperationTagsProcessor());
|
configure.OperationProcessors.Add(new AspNetCoreOperationTagsProcessor());
|
||||||
configure.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("JWT"));
|
configure.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("JWT"));
|
||||||
});
|
});
|
||||||
|
|
||||||
var postgresConnectionString = builder.Configuration.GetConnectionString("PostgresConnection")
|
var postgresConnectionString = builder.Configuration.GetConnectionString("PostgresConnection")
|
||||||
?? throw new InvalidOperationException("Missing ConnectionStrings:PostgresConnection");
|
?? throw new InvalidOperationException("Missing ConnectionStrings:PostgresConnection");
|
||||||
|
|
||||||
builder.Services.AddFastEndpoints();
|
builder.Services.AddFastEndpoints();
|
||||||
builder.Services.AddContentModule(options => options.UseNpgsql(postgresConnectionString));
|
builder.Services.AddContentModule(options =>
|
||||||
builder.Services.AddMessagingModule(options => options.UseNpgsql(postgresConnectionString));
|
options.UseNpgsql(
|
||||||
|
postgresConnectionString,
|
||||||
|
o => o.MigrationsHistoryTable("__EFMigrationsHistory", ContentDbContext.SchemaName)));
|
||||||
|
builder.Services.AddMessagingModule(options =>
|
||||||
|
options.UseNpgsql(
|
||||||
|
postgresConnectionString,
|
||||||
|
o => o.MigrationsHistoryTable("__EFMigrationsHistory", MessagingDbContext.SchemaName)));
|
||||||
|
|
||||||
builder.Services.Configure<JwtOptions>(builder.Configuration.GetRequiredSection(JwtOptions.SectionName));
|
builder.Services.Configure<JwtOptions>(builder.Configuration.GetRequiredSection(JwtOptions.SectionName));
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
dotnet ef database update \
|
||||||
|
--project src/Infrastructure/Infrastructure.csproj \
|
||||||
|
--startup-project src/Web/Web.csproj \
|
||||||
|
--context Hutopy.Infrastructure.Data.ApplicationDbContext \
|
||||||
|
--configuration Debug \
|
||||||
|
--no-build
|
||||||
|
|
||||||
dotnet ef database update \
|
dotnet ef database update \
|
||||||
--project src/Web/Web.csproj \
|
--project src/Web/Web.csproj \
|
||||||
--startup-project src/Web/Web.csproj \
|
--startup-project src/Web/Web.csproj \
|
||||||
--context Hutopy.Web.Features.Messages.Data.MessagingDbContext \
|
--context Hutopy.Web.Features.Messages.Data.MessagingDbContext \
|
||||||
--configuration Debug \
|
--configuration Debug \
|
||||||
--no-build \
|
--no-build
|
||||||
--connection Server=localhost,5432;Database=Hutopy;Uid=sa;Pwd=P@ssword123!;
|
|
||||||
|
|
||||||
dotnet ef database update \
|
dotnet ef database update \
|
||||||
--project src/Web/Web.csproj \
|
--project src/Web/Web.csproj \
|
||||||
--startup-project src/Web/Web.csproj \
|
--startup-project src/Web/Web.csproj \
|
||||||
--context Hutopy.Web.Features.Contents.Data.ContentDbContext \
|
--context Hutopy.Web.Features.Contents.Data.ContentDbContext \
|
||||||
--configuration Debug \
|
--configuration Debug \
|
||||||
--no-build \
|
--no-build
|
||||||
--connection Server=localhost,5432;Database=Hutopy;Uid=sa;Pwd=P@ssword123!;
|
|
||||||
|
|||||||
Reference in New Issue
Block a user