Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC - Just for discussion - Move all runner code except DB specific dependencies into FluentMigrator.Runner.Core #1198

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 0 additions & 74 deletions samples/FluentMigrator.Example.Migrator/Program.Legacy.cs

This file was deleted.

24 changes: 1 addition & 23 deletions samples/FluentMigrator.Example.Migrator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ static int Main(string[] args)
var app = new CommandLineApplication();

var help = app.HelpOption();
var mode = app.Option<MigrationMode>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gliljas Why is this a pre-requisite to achieving this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'm not sure. I believe it was just a victim of making things compile, i.e no legacy stuff.

"-m|--mode <MODE>",
"The mode of the application (legacy or di)",
CommandOptionType.SingleValue);
var processor = app.Option(
"-d|--dialect <DIALECT>",
$"The database dialect ({string.Join(",", DefaultConfigurations.Keys)})",
Expand All @@ -56,20 +52,8 @@ static int Main(string[] args)
app.OnExecute(
() =>
{
var selectedMode = mode.HasValue() ? mode.ParsedValue : MigrationMode.DI;
var dbConfig = CreateDatabaseConfiguration(processor, connectionString);
switch (selectedMode)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gliljas See above. Not clear on why this needs to be removed? I looked at RunInLegacyMode and it doesnt seem to contain any concrete DB driver dependencies? RunWithServices below does, but that should be addressed by creating interfaces and letting people try to register a type if it exists.

The downside I see to hot loading types in RunWithServices is that you move away from deps.json auto-resolving the dependency, so you can end up in situations where a developer has upgraded to a newer version of fluentmigrator, but the build ci/deploy cd servers are on older versions, and thus you get a runtime error due to not resolving dependencies.

{
case MigrationMode.Legacy:
Console.WriteLine(@"Using legacy mode");
RunInLegacyMode(dbConfig);
break;
case MigrationMode.DI:
Console.WriteLine(@"Using dependency injection");
RunWithServices(dbConfig);
break;
}

RunWithServices(dbConfig);
return 0;
});

Expand Down Expand Up @@ -109,11 +93,5 @@ private static DatabaseConfiguration CreateDatabaseConfiguration(CommandOption p

return DefaultDatabaseConfigurations.Sqlite;
}

private enum MigrationMode
{
Legacy,
DI,
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,41 +44,6 @@ public class ConnectionlessVersionLoader : IVersionLoader

private bool _versionsLoaded;

[Obsolete]
internal ConnectionlessVersionLoader(
IMigrationRunner runner,
IAssemblyCollection assemblies,
IConventionSet conventionSet,
IMigrationRunnerConventions conventions,
IRunnerContext runnerContext,
IVersionTableMetaData versionTableMetaData = null)
{
_migrationInformationLoader = runner.MigrationLoader;
_processor = runner.Processor;

Runner = runner;
Assemblies = assemblies;
Conventions = conventions;
StartVersion = runnerContext.StartVersion;
TargetVersion = runnerContext.Version;

VersionInfo = new VersionInfo();
VersionTableMetaData = versionTableMetaData ??
(IVersionTableMetaData)Activator.CreateInstance(assemblies.Assemblies.GetVersionTableMetaDataType(
Conventions, runnerContext));
VersionMigration = new VersionMigration(VersionTableMetaData);
VersionSchemaMigration = new VersionSchemaMigration(VersionTableMetaData);
VersionUniqueMigration = new VersionUniqueMigration(VersionTableMetaData);
VersionDescriptionMigration = new VersionDescriptionMigration(VersionTableMetaData);

if (VersionTableMetaData is DefaultVersionTableMetaData defaultMetaData)
{
conventionSet.SchemaConvention?.Apply(defaultMetaData);
}

LoadVersionInfo();
}

public ConnectionlessVersionLoader(
[NotNull] IProcessorAccessor processorAccessor,
[NotNull] IMigrationRunnerConventions conventions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
<RootNamespace>FluentMigrator.Runner</RootNamespace>
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)../../PackageLibrary.props" />
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System.Configuration" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FluentMigrator.Abstractions\FluentMigrator.Abstractions.csproj" />
<ProjectReference Include="..\FluentMigrator\FluentMigrator.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\FluentMigrator.snk" Link="FluentMigrator.snk" />
Expand All @@ -19,7 +23,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.0.1" />
</ItemGroup>
</Project>
Loading