-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Hi Community.
I managed to get SQL Migrations running by commenting a couple of lines of code in the Apphost, but not fully ideal for a template.
Question i have in order to make it play both ways:
Alternative of nvarcharmax for Payload columns, in stead of jsonb.
On Aspire Startup, how would i go about setting the environment to dictate to start up from SQL, or from postgres.
Sql Db is local for dev, but remote for production.
Almost like what was done in the ConnectionStringValidator class:
switch (dbProvider?.ToUpperInvariant())
{
case DbProviders.PostgreSQL:
// Postgres container + database
var postgres = builder.AddPostgres("postgres").WithDataVolume("fsh-postgres-data").AddDatabase("fsh");
builder.AddProject<Projects.Playground_Api>("playground-api")
.WithReference(postgres)
.WithEnvironment("ASPNETCORE_ENVIRONMENT", "Production")
.WithEnvironment("OpenTelemetryOptions__Exporter__Otlp__Endpoint", "https://localhost:4317")
.WithEnvironment("OpenTelemetryOptions__Exporter__Otlp__Protocol", "grpc")
.WithEnvironment("OpenTelemetryOptions__Exporter__Otlp__Enabled", "true")
.WithEnvironment("DatabaseOptions__Provider", "POSTGRESQL")
.WithEnvironment("DatabaseOptions__ConnectionString", postgres.Resource.ConnectionStringExpression)
.WithEnvironment("DatabaseOptions__MigrationsAssembly", "FSH.Playground.Migrations.PostgreSQL")
.WaitFor(postgres)
.WithReference(redis)
.WithEnvironment("CachingOptions__Redis", redis.Resource.ConnectionStringExpression)
.WaitFor(redis);
break;
case DbProviders.MSSQL:
// SQLcontainer + database
var sqlServer = builder.AddSql("postgres").WithDataVolume("fsh-sql-data").AddDatabase("fsh");
builder.AddProject<Projects.Playground_Api>("playground-api")
.WithReference(sqlServer )
.WithEnvironment("ASPNETCORE_ENVIRONMENT", "Production")
.WithEnvironment("OpenTelemetryOptions__Exporter__Otlp__Endpoint", "https://localhost:4317")
.WithEnvironment("OpenTelemetryOptions__Exporter__Otlp__Protocol", "grpc")
.WithEnvironment("OpenTelemetryOptions__Exporter__Otlp__Enabled", "true")
.WithEnvironment("DatabaseOptions__Provider", "SQL")
.WithEnvironment("DatabaseOptions__ConnectionString", sql.Resource.ConnectionStringExpression)
.WithEnvironment("DatabaseOptions__MigrationsAssembly", "FSH.Playground.Migrations.MSSQL")
.WaitFor(sqlServer )
.WithReference(redis)
.WithEnvironment("CachingOptions__Redis", redis.Resource.ConnectionStringExpression)
.WaitFor(redis);
break;
default:
break;
}