mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Added upgrade database command
--HG-- branch : dev
This commit is contained in:
@@ -149,24 +149,6 @@ namespace Orchard.Tests.DataMigration {
|
||||
}
|
||||
}
|
||||
|
||||
public class StubLoaders : ExtensionLoaderBase {
|
||||
#region Implementation of IExtensionLoader
|
||||
|
||||
public override int Order {
|
||||
get { return 1; }
|
||||
}
|
||||
|
||||
public override ExtensionProbeEntry Probe(ExtensionDescriptor descriptor) {
|
||||
return new ExtensionProbeEntry { Descriptor = descriptor, Loader = this };
|
||||
}
|
||||
|
||||
public override ExtensionEntry Load(ExtensionDescriptor descriptor) {
|
||||
return new ExtensionEntry { Descriptor = descriptor, ExportedTypes = new Type[0] };
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void DataMigrationShouldDoNothingIfNoDataMigrationIsProvidedForFeature() {
|
||||
Init(new Type[] {typeof (DataMigrationEmpty)});
|
||||
|
31
src/Orchard/DataMigration/Commands/DataMigrationCommands.cs
Normal file
31
src/Orchard/DataMigration/Commands/DataMigrationCommands.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using Orchard.Commands;
|
||||
|
||||
namespace Orchard.DataMigration.Commands {
|
||||
public class DataMigrationCommands : DefaultOrchardCommandHandler {
|
||||
private readonly IDataMigrationManager _dataMigrationManager;
|
||||
|
||||
public DataMigrationCommands(
|
||||
IDataMigrationManager dataMigrationManager) {
|
||||
_dataMigrationManager = dataMigrationManager;
|
||||
}
|
||||
|
||||
[OrchardSwitch]
|
||||
public string Feature { get; set; }
|
||||
|
||||
[CommandName("upgrade database")]
|
||||
[CommandHelp("upgrade database /Feature:<feature> \r\n\t" + "Upgrades or create the database tables for the named <feature>")]
|
||||
[OrchardSwitches("Feature")]
|
||||
public string UpgradeDatabase() {
|
||||
try {
|
||||
_dataMigrationManager.Upgrade(Feature);
|
||||
}
|
||||
catch ( Exception ex ) {
|
||||
Context.Output.WriteLine(T("An error occured while upgrading the database: " + ex.Message));
|
||||
return "Upgrade terminated.";
|
||||
}
|
||||
|
||||
return "Database upgraded";
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
namespace Orchard.DataMigration.Commands {
|
||||
namespace Orchard.DataMigration {
|
||||
public interface IDataMigrationCommand {
|
||||
}
|
||||
}
|
@@ -348,7 +348,8 @@
|
||||
<Compile Include="ContentManagement\ViewModels\TemplateViewModel.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DataMigration\Commands\IDataMigrationCommand.cs" />
|
||||
<Compile Include="DataMigration\Commands\DataMigrationCommands.cs" />
|
||||
<Compile Include="DataMigration\IDataMigrationCommand.cs" />
|
||||
<Compile Include="DataMigration\DefaultDataMigrationGenerator.cs" />
|
||||
<Compile Include="DataMigration\IDataMigrationGenerator.cs" />
|
||||
<Compile Include="DataMigration\DataMigration.cs" />
|
||||
|
Reference in New Issue
Block a user