mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 10:42:08 +00:00
Restructure project
This commit is contained in:
32
Database/Database.Core/Program.cs
Normal file
32
Database/Database.Core/Program.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
// Get connection string from environment variable
|
||||
|
||||
using System.Reflection;
|
||||
using DbUp;
|
||||
|
||||
var connectionString = Environment.GetEnvironmentVariable(
|
||||
"DB_CONNECTION_STRING"
|
||||
);
|
||||
|
||||
var upgrader = DeployChanges
|
||||
.To.SqlDatabase(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;
|
||||
Reference in New Issue
Block a user