Im trying to use the example code from dbup converted to postgres.
Below is the code.
using System;
using System.Linq;
using System.Reflection;
using DbUp;
namespace GeoServerDbManager
{
//"Host = 1.1.1.1; User Id = postgres; Password = postgres; Database = osmdev; Port = 5432"
class Program
{
static int Main(string[] args)
{
var connectionString =
args.FirstOrDefault()
?? "Host = 1.1.1.1; User Id = postgres; Password = postgres; Database = osmdev; Port = 5432";
EnsureDatabase.For.PostgresqlDatabase(connectionString);
var upgrader =
DeployChanges.To
.PostgresqlDatabase(connectionString)
.WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly())
.LogToConsole()
.Build();
var result = upgrader.PerformUpgrade();
if (!result.Successful)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(result.Error);
Console.ResetColor();
#if DEBUG
Console.ReadLine();
#endif
return -1;
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Success!");
Console.ResetColor();
return 0;
}
}
}
The database doesnt exist when I run this. I keep getting the error:
Script block number: 0; Message: 42P01: relation "schemaversions" does not exist
Npgsql.PostgresException (0x80004005): 42P01: relation "schemaversions" does not exist
The tables do get created and so does the schemaversions table but the schemaversions table is empty at the end of the script.