3b76070394
✅ Database Setup: - Created PostgreSQL kartselldb with kartsell user - SSH port forward established (localhost:5432 → 178.104.200.7:5432) ✅ DbMigrator Fixes: - Fixed migration path discovery (AppContext.BaseDirectory fallback) - Added empty variable dictionary to suppress DbUp preprocessing - Fixed PostgreSQL dollar quoting conflict ($policy$ → $$) ✅ Migration Results: - All 21 migrations executed successfully - Schema versions journal created and tracked - 21 scripts processed in order, no rollback needed Status: FRESH DATABASE DEPLOYMENT SUCCESSFUL - kartselldb fully initialized with v16 schema - Ready for application startup Next: Deploy application and run integration tests Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using DbUp;
|
|
|
|
var connectionString = Environment.GetEnvironmentVariable("KARTSELL_POSTGRES")
|
|
?? "Host=localhost;Port=5432;Database=kartsell;Username=kartsell;Password=kartsell";
|
|
|
|
var scriptsPath = Path.Combine(AppContext.BaseDirectory, "db", "migrations");
|
|
if (!Directory.Exists(scriptsPath))
|
|
{
|
|
scriptsPath = Path.Combine(AppContext.BaseDirectory, "migrations");
|
|
}
|
|
if (!Directory.Exists(scriptsPath))
|
|
{
|
|
// Fallback: SQL files are copied to bin root in flattened structure
|
|
scriptsPath = AppContext.BaseDirectory;
|
|
}
|
|
|
|
EnsureDatabase.For.PostgresqlDatabase(connectionString);
|
|
|
|
var result = DeployChanges.To
|
|
.PostgresqlDatabase(connectionString)
|
|
.WithScriptsFromFileSystem(scriptsPath)
|
|
.WithVariables(new Dictionary<string, string>())
|
|
.JournalToPostgresqlTable("public", "kartsell_schema_versions")
|
|
.LogToConsole()
|
|
.Build()
|
|
.PerformUpgrade();
|
|
|
|
if (!result.Successful)
|
|
{
|
|
Console.Error.WriteLine(result.Error);
|
|
return 1;
|
|
}
|
|
|
|
Console.WriteLine("Database migration completed.");
|
|
return 0;
|