Skip to content

Commit 2ec5ba3

Browse files
committed
* Moved same properties in options to single base class
1 parent 15d613d commit 2ec5ba3

4 files changed

Lines changed: 27 additions & 40 deletions

File tree

src/PostgreSQL.Migrations.Console/Options/ApplyOptions.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,8 @@ namespace PostgreSQL.Migrations.Console.Options
44
{
55

66
[Verb("apply", HelpText = "Apply all new migrations to database(s).")]
7-
public class ApplyOptions
7+
public class ApplyOptions : DatabaseAdjustments
88
{
9-
10-
[Option('f', "files", Required = true, HelpText = "List of files containing migrations.")]
11-
public IEnumerable<string> Files { get; set; } = Enumerable.Empty<string>();
12-
13-
[Option ( 'c', "connectionStrings", Required = true, HelpText = "List of connection strings to which migrations will be applied." )]
14-
public IEnumerable<string> ConnectionStrings { get; set; } = Enumerable.Empty<string> ();
15-
16-
[Option ('s', "strategy", Default = "MigrationResolverAttribute", HelpText = "Select strategy for read migrations.")]
17-
public string Strategy { get; set; } = "";
18-
19-
[Option('g', "group", HelpText = "If you specify some group or groups (separated by commas), migrations will be filtered by these groups")]
20-
public string Group { get; set; } = "";
21-
229
}
2310

2411
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using CommandLine;
2+
3+
namespace PostgreSQL.Migrations.Console.Options {
4+
5+
/// <summary>
6+
/// Database adjustments.
7+
/// </summary>
8+
public class DatabaseAdjustments {
9+
10+
[Option ( 'f', "files", Required = true, HelpText = "List of files containing migrations." )]
11+
public IEnumerable<string> Files { get; set; } = Enumerable.Empty<string> ();
12+
13+
[Option ( 'c', "connectionStrings", Required = true, HelpText = "List of connection strings to which migrations will be applied." )]
14+
public IEnumerable<string> ConnectionStrings { get; set; } = Enumerable.Empty<string> ();
15+
16+
[Option ( 's', "strategy", Default = "MigrationResolverAttribute", HelpText = "Select strategy for read migrations." )]
17+
public string Strategy { get; set; } = "";
18+
19+
[Option ( 'g', "group", HelpText = "If you specify some group or groups (separated by commas), migrations will be filtered by these groups." )]
20+
public string Group { get; set; } = "";
21+
22+
}
23+
24+
}

src/PostgreSQL.Migrations.Console/Options/ForceRevertOptions.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@
33
namespace PostgreSQL.Migrations.Console.Options {
44

55
[Verb ( "force-revert", HelpText = "Revert only one migration specified in parameter." )]
6-
public class ForceRevertOptions {
7-
8-
[Option ( 'f', "files", Required = true, HelpText = "List of files containing migrations." )]
9-
public IEnumerable<string> Files { get; set; } = Enumerable.Empty<string> ();
10-
11-
[Option ( 'c', "connectionStrings", Required = true, HelpText = "List of connection strings to which migrations will be applied." )]
12-
public IEnumerable<string> ConnectionStrings { get; set; } = Enumerable.Empty<string> ();
13-
14-
[Option ( 's', "strategy", Default = "MigrationResolverAttribute", HelpText = "Select strategy for read migrations." )]
15-
public string Strategy { get; set; } = "";
16-
17-
[Option ( 'g', "group", HelpText = "If you specify some group or groups (separated by commas), migrations will be filtered by these groups." )]
18-
public string Group { get; set; } = "";
6+
public class ForceRevertOptions : DatabaseAdjustments {
197

208
[Option ( 'm', "migration", Required = true, HelpText = "The parameter specifies the number of the migration which will be reverted (if it was applied before) and after it applied once again." )]
219
public int Migration { get; set; } = 0;

src/PostgreSQL.Migrations.Console/Options/RevertOptions.cs

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@
33
namespace PostgreSQL.Migrations.Console.Options {
44

55
[Verb ( "revert", HelpText = "Revert database to state before migration specified in parameter." )]
6-
public class RevertOptions {
7-
8-
[Option ( 'f', "files", Required = true, HelpText = "List of files containing migrations." )]
9-
public IEnumerable<string> Files { get; set; } = Enumerable.Empty<string> ();
10-
11-
[Option ( 'c', "connectionStrings", Required = true, HelpText = "List of connection strings to which migrations will be applied." )]
12-
public IEnumerable<string> ConnectionStrings { get; set; } = Enumerable.Empty<string> ();
13-
14-
[Option ( 's', "strategy", Default = "MigrationResolverAttribute", HelpText = "Select strategy for read migrations." )]
15-
public string Strategy { get; set; } = "";
16-
17-
[Option ( 'g', "group", HelpText = "If you specify some group or groups (separated by commas), migrations will be filtered by these groups." )]
18-
public string Group { get; set; } = "";
6+
public class RevertOptions : DatabaseAdjustments {
197

208
[Option ( 'm', "migration", Required = true, HelpText = "The parameter specifies the number of the migration to which you want to roll back the changes." )]
219
public int Migration { get; set; } = 0;

0 commit comments

Comments
 (0)