mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-19 18:27:55 +08:00
Don't recreate tables if an error occured during the second phase setup (homepage creation)
--HG-- branch : dev
This commit is contained in:
@@ -8,6 +8,7 @@ using Orchard.Core.Common.Models;
|
|||||||
using Orchard.Core.Common.Settings;
|
using Orchard.Core.Common.Settings;
|
||||||
using Orchard.Core.Navigation.Models;
|
using Orchard.Core.Navigation.Models;
|
||||||
using Orchard.Core.Routable.Models;
|
using Orchard.Core.Routable.Models;
|
||||||
|
using Orchard.Core.Settings.Descriptor.Records;
|
||||||
using Orchard.Core.Settings.Models;
|
using Orchard.Core.Settings.Models;
|
||||||
using Orchard.Data;
|
using Orchard.Data;
|
||||||
using Orchard.Data.Migration.Interpreters;
|
using Orchard.Data.Migration.Interpreters;
|
||||||
@@ -108,28 +109,36 @@ namespace Orchard.Setup.Services {
|
|||||||
|
|
||||||
// initialize database explicitly, and store shell descriptor
|
// initialize database explicitly, and store shell descriptor
|
||||||
var bootstrapLifetimeScope = _shellContainerFactory.CreateContainer(shellSettings, shellToplogy);
|
var bootstrapLifetimeScope = _shellContainerFactory.CreateContainer(shellSettings, shellToplogy);
|
||||||
using (var environment = new StandaloneEnvironment(bootstrapLifetimeScope)) {
|
using ( var environment = new StandaloneEnvironment(bootstrapLifetimeScope) ) {
|
||||||
|
|
||||||
var schemaBuilder = new SchemaBuilder(environment.Resolve<IDataMigrationInterpreter>() );
|
// check if the database is already created (in case an exception occured in the second phase)
|
||||||
var reportsCoordinator = environment.Resolve<IReportsCoordinator>();
|
var shellDescriptorRepository = environment.Resolve<IRepository<ShellDescriptorRecord>>();
|
||||||
|
try {
|
||||||
reportsCoordinator.Register("Data Migration", "Setup", "Orchard installation");
|
shellDescriptorRepository.Get(x => true);
|
||||||
|
|
||||||
schemaBuilder.CreateTable("Orchard_Framework_DataMigrationRecord", table => table
|
|
||||||
.Column<int>("Id", column => column.PrimaryKey().Identity())
|
|
||||||
.Column<string>("DataMigrationClass")
|
|
||||||
.Column<int>("Version"));
|
|
||||||
|
|
||||||
var dataMigrationManager = environment.Resolve<IDataMigrationManager>();
|
|
||||||
|
|
||||||
foreach ( var feature in context.EnabledFeatures ) {
|
|
||||||
dataMigrationManager.Update(feature);
|
|
||||||
}
|
}
|
||||||
|
catch {
|
||||||
|
var schemaBuilder = new SchemaBuilder(environment.Resolve<IDataMigrationInterpreter>());
|
||||||
|
var reportsCoordinator = environment.Resolve<IReportsCoordinator>();
|
||||||
|
|
||||||
environment.Resolve<IShellDescriptorManager>().UpdateShellDescriptor(
|
reportsCoordinator.Register("Data Migration", "Setup", "Orchard installation");
|
||||||
0,
|
|
||||||
shellDescriptor.Features,
|
schemaBuilder.CreateTable("Orchard_Framework_DataMigrationRecord",
|
||||||
shellDescriptor.Parameters);
|
table => table
|
||||||
|
.Column<int>("Id", column => column.PrimaryKey().Identity())
|
||||||
|
.Column<string>("DataMigrationClass")
|
||||||
|
.Column<int>("Version"));
|
||||||
|
|
||||||
|
var dataMigrationManager = environment.Resolve<IDataMigrationManager>();
|
||||||
|
|
||||||
|
foreach ( var feature in context.EnabledFeatures ) {
|
||||||
|
dataMigrationManager.Update(feature);
|
||||||
|
}
|
||||||
|
|
||||||
|
environment.Resolve<IShellDescriptorManager>().UpdateShellDescriptor(
|
||||||
|
0,
|
||||||
|
shellDescriptor.Features,
|
||||||
|
shellDescriptor.Parameters);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// in effect "pump messages" see PostMessage circa 1980
|
// in effect "pump messages" see PostMessage circa 1980
|
||||||
|
Reference in New Issue
Block a user