-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
57 lines (42 loc) · 1.33 KB
/
Program.cs
File metadata and controls
57 lines (42 loc) · 1.33 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
52
53
54
using MySqlDiffSharp.Models;
using MySqlDiffSharp.Utils;
using static MySqlDiffSharp.Utils.ConsoleUtils;
var config = new AppConfig(args);
if (config.ShowHelp || args.Length < 2)
{
PrintHelp();
return 0;
}
string arg1 = config.PositionalArgs[0];
string arg2 = config.PositionalArgs[1];
Log($"Parsing database 1: {arg1}");
var db1 = new Database(arg1, config, 1);
Log($"Parsing database 2: {arg2}");
var db2 = new Database(arg2, config, 2);
Log("Comparing databases...");
string diffs = DiffEngine.Compare(db1, db2, config);
if (string.IsNullOrWhiteSpace(diffs))
{
Log("No differences found.");
return 0;
}
Log("Diffs ready:");
Log("########################################################");
Console.Write(diffs);
Console.WriteLine();
Log("########################################################");
if (config.BatchApply || config.Apply)
{
if (!config.BatchApply)
{
Log($"\nApply above changes to {db2.Name} [y/N] ? ");
if (diffs.Contains("DROP TABLE", StringComparison.OrdinalIgnoreCase))
Log("(CAUTION! Changes contain DROP TABLE commands.)");
var reply = Console.ReadLine()?.Trim().ToLowerInvariant();
if (reply != "y" && reply != "yes")
return 0;
}
await DiffEngine.ApplyDiffAsync(db2, diffs);
Log("Successfully applied changes.");
}
return 0;