-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeedsCommand.cs
42 lines (33 loc) · 1.13 KB
/
SeedsCommand.cs
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
using DbUp.ScriptProviders;
namespace Migratonator;
internal class SeedsCommand : BaseCommand
{
// TODO: make well-known directories configurable
// the path to seeds scripts, relative to the base script path
private const string SeedsPath = "Seeds";
public SeedsCommand(Options configuration, bool dryRun) :
base(configuration)
{
DryRun = dryRun;
}
private bool DryRun { get; }
public override void Perform()
{
var builder = CreateUnJournaledMigrator();
var qualifiedPath = Path.Combine(Options.ScriptsPath, SeedsPath);
if (Directory.Exists(qualifiedPath))
{
builder.WithScripts(new FileSystemScriptProvider(qualifiedPath));
}
else
{
Console.WriteLine($"WARNING: {qualifiedPath} path not found. Ignoring.");
return;
}
// inject the SeedsPath variable and pre-processor
builder = builder
.WithVariable("SeedsPath", qualifiedPath)
.WithPreprocessor(new SeedsPreprocessor(qualifiedPath));
Apply(builder.Build(), DryRun, Options.Confirm, false);
}
}