-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMigrateCreateCommand.cs
More file actions
30 lines (25 loc) · 940 Bytes
/
Copy pathMigrateCreateCommand.cs
File metadata and controls
30 lines (25 loc) · 940 Bytes
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
namespace Migratonator;
internal class MigrateCreateCommand : BaseCommand
{
public MigrateCreateCommand(Options configuration, string name) :
base(configuration)
{
Name = name;
}
private string Name { get; }
public override void Perform()
{
var now = DateTime.Now;
var dateStamp = now.ToString("yyyyMMddHHmmss");
var cleanedName = Name.Replace(" ", "-");
var fileName = $"{dateStamp}-{cleanedName}.sql";
using var writer =
File.CreateText(Path.Combine(Options.ScriptsPath, MigrationPath, fileName));
writer.WriteLine("-- TODO: write migration script");
writer.WriteLine("-- Use $DatabaseName$ and $SchemaName$ variables to reference the database and schema names");
writer.WriteLine();
writer.WriteLine("GO");
writer.WriteLine();
ReportSuccess($"Created migration script '{fileName}'!");
}
}