Skip to content

Commit

Permalink
Tabs to spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellee committed Oct 21, 2012
1 parent 365f5a9 commit 0645ab8
Show file tree
Hide file tree
Showing 5 changed files with 1,249 additions and 1,249 deletions.
32 changes: 16 additions & 16 deletions src/FluentMigrator.Runner/IMigrationRunner.cs
@@ -1,17 +1,17 @@
using System.Reflection;

namespace FluentMigrator.Runner
{
public interface IMigrationRunner
{
IMigrationProcessor Processor { get; }
Assembly MigrationAssembly { get; }
void Up(IMigration migration);
void MigrateUp();
void MigrateUp(long version);
void Rollback(int steps);
void RollbackToVersion(long version);
void MigrateDown(long version);
void ValidateVersionOrder();
}
using System.Reflection;

namespace FluentMigrator.Runner
{
public interface IMigrationRunner
{
IMigrationProcessor Processor { get; }
Assembly MigrationAssembly { get; }
void Up(IMigration migration);
void MigrateUp();
void MigrateUp(long version);
void Rollback(int steps);
void RollbackToVersion(long version);
void MigrateDown(long version);
void ValidateVersionOrder();
}
}
214 changes: 107 additions & 107 deletions src/FluentMigrator.Runner/Initialization/TaskExecutor.cs
@@ -1,108 +1,108 @@
#region License
//
// Copyright (c) 2007-2009, Sean Chambers <schambers80@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion

using System;
using FluentMigrator.Runner.Initialization.AssemblyLoader;
using FluentMigrator.Runner.Processors;

namespace FluentMigrator.Runner.Initialization
{
public class TaskExecutor
{
protected IMigrationRunner Runner { get; set; }
private IRunnerContext RunnerContext { get; set; }

public TaskExecutor(IRunnerContext runnerContext)
{
if (runnerContext == null)
throw new ArgumentNullException("runnerContext", "RunnerContext cannot be null");

RunnerContext = runnerContext;
}

protected virtual void Initialize()
{
var assembly = AssemblyLoaderFactory.GetAssemblyLoader(RunnerContext.Target).Load();

var processor = InitializeProcessor(assembly.Location);

Runner = new MigrationRunner(assembly, RunnerContext, processor);
}

public void Execute()
{
Initialize();

switch (RunnerContext.Task)
{
case null:
case "":
case "migrate":
case "migrate:up":
if (RunnerContext.Version != 0)
Runner.MigrateUp(RunnerContext.Version);
else
Runner.MigrateUp();
break;
case "rollback":
if (RunnerContext.Steps == 0)
RunnerContext.Steps = 1;
Runner.Rollback(RunnerContext.Steps);
break;
case "rollback:toversion":
Runner.RollbackToVersion(RunnerContext.Version);
break;
case "rollback:all":
Runner.RollbackToVersion(0);
break;
case "migrate:down":
Runner.MigrateDown(RunnerContext.Version);
break;
case "validateversionorder":
Runner.ValidateVersionOrder();
break;
}

RunnerContext.Announcer.Say("Task completed.");
}

private IMigrationProcessor InitializeProcessor(string assemblyLocation)
{
var manager = new ConnectionStringManager(new NetConfigManager(), RunnerContext.Announcer, RunnerContext.Connection, RunnerContext.ConnectionStringConfigPath, assemblyLocation, RunnerContext.Database);

manager.LoadConnectionString();

if (RunnerContext.Timeout == 0)
{
RunnerContext.Timeout = 30; // Set default timeout for command
}

var processorFactory = ProcessorFactory.GetFactory(RunnerContext.Database);
if (processorFactory == null)
throw new ProcessorFactoryNotFoundException(string.Format("The provider or dbtype parameter is incorrect. Available choices are {0}: ", ProcessorFactory.ListAvailableProcessorTypes()));

var processor = processorFactory.Create(manager.ConnectionString, RunnerContext.Announcer, new ProcessorOptions
{
PreviewOnly = RunnerContext.PreviewOnly,
Timeout = RunnerContext.Timeout
});

return processor;
}
}
#region License
//
// Copyright (c) 2007-2009, Sean Chambers <schambers80@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
#endregion

using System;
using FluentMigrator.Runner.Initialization.AssemblyLoader;
using FluentMigrator.Runner.Processors;

namespace FluentMigrator.Runner.Initialization
{
public class TaskExecutor
{
protected IMigrationRunner Runner { get; set; }
private IRunnerContext RunnerContext { get; set; }

public TaskExecutor(IRunnerContext runnerContext)
{
if (runnerContext == null)
throw new ArgumentNullException("runnerContext", "RunnerContext cannot be null");

RunnerContext = runnerContext;
}

protected virtual void Initialize()
{
var assembly = AssemblyLoaderFactory.GetAssemblyLoader(RunnerContext.Target).Load();

var processor = InitializeProcessor(assembly.Location);

Runner = new MigrationRunner(assembly, RunnerContext, processor);
}

public void Execute()
{
Initialize();

switch (RunnerContext.Task)
{
case null:
case "":
case "migrate":
case "migrate:up":
if (RunnerContext.Version != 0)
Runner.MigrateUp(RunnerContext.Version);
else
Runner.MigrateUp();
break;
case "rollback":
if (RunnerContext.Steps == 0)
RunnerContext.Steps = 1;
Runner.Rollback(RunnerContext.Steps);
break;
case "rollback:toversion":
Runner.RollbackToVersion(RunnerContext.Version);
break;
case "rollback:all":
Runner.RollbackToVersion(0);
break;
case "migrate:down":
Runner.MigrateDown(RunnerContext.Version);
break;
case "validateversionorder":
Runner.ValidateVersionOrder();
break;
}

RunnerContext.Announcer.Say("Task completed.");
}

private IMigrationProcessor InitializeProcessor(string assemblyLocation)
{
var manager = new ConnectionStringManager(new NetConfigManager(), RunnerContext.Announcer, RunnerContext.Connection, RunnerContext.ConnectionStringConfigPath, assemblyLocation, RunnerContext.Database);

manager.LoadConnectionString();

if (RunnerContext.Timeout == 0)
{
RunnerContext.Timeout = 30; // Set default timeout for command
}

var processorFactory = ProcessorFactory.GetFactory(RunnerContext.Database);
if (processorFactory == null)
throw new ProcessorFactoryNotFoundException(string.Format("The provider or dbtype parameter is incorrect. Available choices are {0}: ", ProcessorFactory.ListAvailableProcessorTypes()));

var processor = processorFactory.Create(manager.ConnectionString, RunnerContext.Announcer, new ProcessorOptions
{
PreviewOnly = RunnerContext.PreviewOnly,
Timeout = RunnerContext.Timeout
});

return processor;
}
}
}
4 changes: 2 additions & 2 deletions src/FluentMigrator.Runner/MigrationRunner.cs
Expand Up @@ -394,7 +394,7 @@ private long Time(Action action)
}

public void ValidateVersionOrder()
{
{
IEnumerable<KeyValuePair<long, IMigration>> unappliedVersions = MigrationLoader.Migrations.Where(kvp => MigrationVersionLessThanGreatestAppliedMigration(kvp.Key));

if (unappliedVersions.Any())
Expand All @@ -403,7 +403,7 @@ public void ValidateVersionOrder()
}

_announcer.Say("Version ordering valid.");
}
}

private bool MigrationVersionLessThanGreatestAppliedMigration(long version)
{
Expand Down

0 comments on commit 0645ab8

Please sign in to comment.