Point the design-time factory at the stack the repo ships

`dotnet ef database update --project src/DodoSSH.Infrastructure` — the
command the README documents — failed on a clean machine. The design-time
default named `dodossh_design` as user `postgres` with no password, which is
a database this repository never creates, while the development compose
stack creates `dodossh`/`dodossh`. The failure arrives as a SCRAM
authentication error, so it reads like a broken container rather than a
stale default.

The default is now the compose stack, since that is the only local database
the repo defines. DODOSSH_DESIGN_CONNECTION still overrides it, and a real
deployment migrates through that or the migrator job.

Also documents running the thing end to end, which the README never covered:
the four commands in order, that migrations are a separate step because the
API deliberately fails readiness rather than migrating, and the three M1 gaps
visible in the first five minutes — so they are expected rather than
diagnosed.
This commit is contained in:
2026-07-29 12:17:59 +02:00
parent 34304b989b
commit b9e7c258ae
2 changed files with 55 additions and 4 deletions
@@ -17,14 +17,28 @@ public sealed class DodoDbContextFactory : IDesignTimeDbContextFactory<DodoDbCon
/// <summary>Environment variable naming the database to work against.</summary>
/// <remarks>
/// Only <c>database update</c> and <c>dbcontext script</c> actually connect. Generating a migration
/// needs a provider but not a reachable server, which is why there is a usable default at all.
/// needs a provider but not a reachable server, which is why the default below is allowed to be a
/// guess at all.
/// </remarks>
public const string ConnectionVariable = "DODOSSH_DESIGN_CONNECTION";
/// <summary>
/// Where <c>dotnet ef</c> connects when nothing says otherwise.
/// </summary>
/// <remarks>
/// The development compose stack, because that is the only local database this repository defines. A
/// default naming a server nobody creates makes the documented <c>dotnet ef database update</c> fail on
/// every clean machine, which is a poor first impression of a self-hosted product — and the failure
/// arrives as a SCRAM authentication error, which reads like a broken stack rather than a stale
/// default. These credentials are the compose file's own; a real deployment migrates through
/// <see cref="ConnectionVariable"/> or the migrator job.
/// </remarks>
private const string DevelopmentStackConnection =
"Host=localhost;Port=5432;Database=dodossh;Username=dodossh;Password=dodossh";
/// <inheritdoc />
public DodoDbContext CreateDbContext(string[] args) =>
Create(Environment.GetEnvironmentVariable(ConnectionVariable)
?? "Host=localhost;Database=dodossh_design;Username=postgres");
Create(Environment.GetEnvironmentVariable(ConnectionVariable) ?? DevelopmentStackConnection);
/// <summary>
/// Builds a context for one database, configured as the API configures its own.