-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
51 lines (44 loc) · 1.5 KB
/
Program.cs
File metadata and controls
51 lines (44 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Linq;
using System.Reflection;
using DbUp;
using DbUp.MySql;
using DbUp.Engine.Output;
using MySql.Data.MySqlClient;
namespace dbupmysql.Database
{
class Program
{
static int Main(string[] args)
{
var environmentVariableConnectionString = Environment.GetEnvironmentVariable("DbUpConnectionString");
var connectionString = environmentVariableConnectionString == null ? args.FirstOrDefault() ?? "server=127.0.0.1;port=3306;database=test;user=root;password=passwordsecret;" : environmentVariableConnectionString;
Console.WriteLine(connectionString);
EnsureDatabase.For.MySqlDatabase(connectionString);
var upgrader =
DeployChanges.To
.MySqlDatabase(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();
#if DEBUG
Console.ReadLine();
#endif
return 0;
}
}
}