Skip to content

Commit

Permalink
* Moved same properties in options to single base class
Browse files Browse the repository at this point in the history
  • Loading branch information
trueromanus committed Aug 30, 2023
1 parent 15d613d commit 2ec5ba3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 40 deletions.
15 changes: 1 addition & 14 deletions src/PostgreSQL.Migrations.Console/Options/ApplyOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,8 @@ namespace PostgreSQL.Migrations.Console.Options
{

[Verb("apply", HelpText = "Apply all new migrations to database(s).")]
public class ApplyOptions
public class ApplyOptions : DatabaseAdjustments
{

[Option('f', "files", Required = true, HelpText = "List of files containing migrations.")]
public IEnumerable<string> Files { get; set; } = Enumerable.Empty<string>();

[Option ( 'c', "connectionStrings", Required = true, HelpText = "List of connection strings to which migrations will be applied." )]
public IEnumerable<string> ConnectionStrings { get; set; } = Enumerable.Empty<string> ();

[Option ('s', "strategy", Default = "MigrationResolverAttribute", HelpText = "Select strategy for read migrations.")]
public string Strategy { get; set; } = "";

[Option('g', "group", HelpText = "If you specify some group or groups (separated by commas), migrations will be filtered by these groups")]
public string Group { get; set; } = "";

}

}
24 changes: 24 additions & 0 deletions src/PostgreSQL.Migrations.Console/Options/DatabaseAdjustments.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using CommandLine;

namespace PostgreSQL.Migrations.Console.Options {

/// <summary>
/// Database adjustments.
/// </summary>
public class DatabaseAdjustments {

[Option ( 'f', "files", Required = true, HelpText = "List of files containing migrations." )]
public IEnumerable<string> Files { get; set; } = Enumerable.Empty<string> ();

[Option ( 'c', "connectionStrings", Required = true, HelpText = "List of connection strings to which migrations will be applied." )]
public IEnumerable<string> ConnectionStrings { get; set; } = Enumerable.Empty<string> ();

[Option ( 's', "strategy", Default = "MigrationResolverAttribute", HelpText = "Select strategy for read migrations." )]
public string Strategy { get; set; } = "";

[Option ( 'g', "group", HelpText = "If you specify some group or groups (separated by commas), migrations will be filtered by these groups." )]
public string Group { get; set; } = "";

}

}
14 changes: 1 addition & 13 deletions src/PostgreSQL.Migrations.Console/Options/ForceRevertOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,7 @@
namespace PostgreSQL.Migrations.Console.Options {

[Verb ( "force-revert", HelpText = "Revert only one migration specified in parameter." )]
public class ForceRevertOptions {

[Option ( 'f', "files", Required = true, HelpText = "List of files containing migrations." )]
public IEnumerable<string> Files { get; set; } = Enumerable.Empty<string> ();

[Option ( 'c', "connectionStrings", Required = true, HelpText = "List of connection strings to which migrations will be applied." )]
public IEnumerable<string> ConnectionStrings { get; set; } = Enumerable.Empty<string> ();

[Option ( 's', "strategy", Default = "MigrationResolverAttribute", HelpText = "Select strategy for read migrations." )]
public string Strategy { get; set; } = "";

[Option ( 'g', "group", HelpText = "If you specify some group or groups (separated by commas), migrations will be filtered by these groups." )]
public string Group { get; set; } = "";
public class ForceRevertOptions : DatabaseAdjustments {

[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." )]
public int Migration { get; set; } = 0;
Expand Down
14 changes: 1 addition & 13 deletions src/PostgreSQL.Migrations.Console/Options/RevertOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,7 @@
namespace PostgreSQL.Migrations.Console.Options {

[Verb ( "revert", HelpText = "Revert database to state before migration specified in parameter." )]
public class RevertOptions {

[Option ( 'f', "files", Required = true, HelpText = "List of files containing migrations." )]
public IEnumerable<string> Files { get; set; } = Enumerable.Empty<string> ();

[Option ( 'c', "connectionStrings", Required = true, HelpText = "List of connection strings to which migrations will be applied." )]
public IEnumerable<string> ConnectionStrings { get; set; } = Enumerable.Empty<string> ();

[Option ( 's', "strategy", Default = "MigrationResolverAttribute", HelpText = "Select strategy for read migrations." )]
public string Strategy { get; set; } = "";

[Option ( 'g', "group", HelpText = "If you specify some group or groups (separated by commas), migrations will be filtered by these groups." )]
public string Group { get; set; } = "";
public class RevertOptions : DatabaseAdjustments {

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

0 comments on commit 2ec5ba3

Please sign in to comment.