Skip to content

Commit 2c33bcc

Browse files
author
Łukasz Halicki
committed
fixed some aspire issues
1 parent 10af0f5 commit 2c33bcc

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

src/Aspire.AppHost/Program.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33
IDistributedApplicationBuilder builder = DistributedApplication.CreateBuilder(args);
44

55
IResourceBuilder<PostgresDatabaseResource> database = builder
6-
.AddPostgres("database")
6+
.AddPostgres("SQL-Database")
77
.WithImage("postgres:17")
8+
.WithHostPort(5432)
89
.WithBindMount("../../.containers/db", "/var/lib/postgresql/data")
910
.AddDatabase("clean-architecture");
1011

1112
IResourceBuilder<PapercutSmtpContainerResource> papercut = builder
12-
.AddPapercutSmtp("papercut")
13+
.AddPapercutSmtp("SMTP-Papercut", httpPort: 2115, smtpPort: 1337)
1314
.WithHttpHealthCheck(path: "/");
1415

15-
builder.AddProject<Projects.Web_Api>("web-api")
16+
builder.AddProject<Projects.Web_Api>("Web-API")
1617
.WithEnvironment("ConnectionStrings__Database", database)
1718
.WithReference(papercut)
1819
.WithReference(database)

src/Infrastructure/Database/ApplicationDbContext.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,18 @@ public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext>
1717
: DbContext(options), IApplicationDbContext
1818
{
1919
public DbSet<User> Users { get; set; }
20-
2120
public DbSet<Address> Addresss { get; set; }
22-
2321
public DbSet<Cart> Carts { get; set; }
24-
2522
public DbSet<CartItem> CartItems { get; set; }
26-
2723
public DbSet<Category> Categories { get; set; }
28-
2924
public DbSet<Order> Orders { get; set; }
30-
3125
public DbSet<OrderItem> OrderItems { get; set; }
32-
3326
public DbSet<Product> Products { get; set; }
34-
3527
public DbSet<Review> Reviews { get; set; }
36-
3728
public DbSet<Inventory> Inventories { get; set; }
38-
3929
public DbSet<EmailVerificationToken> EmailVerificationTokens { get; set; }
40-
4130
public DbSet<Role> Roles { get; set; }
42-
4331
public DbSet<UserClaim> UserClaims { get; set; }
44-
4532
public DbSet<RoleClaim> UserRoles { get; set; }
4633

4734
protected override void OnModelCreating(ModelBuilder modelBuilder)

src/Infrastructure/Infrastructure.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@
1919
<InternalsVisibleTo Include="ArchitectureTests" />
2020
</ItemGroup>
2121

22+
<ItemGroup>
23+
<Folder Include="Database\Migrations\" />
24+
</ItemGroup>
25+
2226
</Project>

src/Web.Api/Extensions/MigrationExtensions.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ public static void ApplyMigrations(this IApplicationBuilder app)
1111

1212
using ApplicationDbContext dbContext =
1313
scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
14+
try
15+
{
16+
dbContext.Database.Migrate();
17+
} catch
18+
{
19+
//App can continue even if migration fails
20+
}
1421

15-
dbContext.Database.Migrate();
1622
}
1723
}

0 commit comments

Comments
 (0)