mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Work Items: 18116, 18082 --HG-- branch : 1.x
This commit is contained in:
@@ -1,7 +1,23 @@
|
|||||||
namespace Orchard.Data.Migration.Records {
|
using FluentNHibernate.Mapping;
|
||||||
|
|
||||||
|
namespace Orchard.Data.Migration.Records {
|
||||||
public class DataMigrationRecord {
|
public class DataMigrationRecord {
|
||||||
public virtual int Id { get; set; }
|
public virtual int Id { get; set; }
|
||||||
public virtual string DataMigrationClass { get; set; }
|
public virtual string DataMigrationClass { get; set; }
|
||||||
public virtual int Version { get; set; }
|
public virtual int Version { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Since the "Version" colmuns is "AutoMapped" in FluentNHibernate, and the currently used version
|
||||||
|
/// doesn't understand IVersionConvention and IVersionConventionAcceptance, we need to provide a manual
|
||||||
|
/// mapping.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class DataMigrationRecordMap : ClassMap<DataMigrationRecord> {
|
||||||
|
public DataMigrationRecordMap() {
|
||||||
|
Table("Orchard_Framework_DataMigrationRecord");
|
||||||
|
Id(x => x.Id);
|
||||||
|
Map(x => x.DataMigrationClass);
|
||||||
|
Map(x => x.Version);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ using FluentNHibernate.Conventions.Helpers;
|
|||||||
using NHibernate.Cfg;
|
using NHibernate.Cfg;
|
||||||
using Orchard.ContentManagement.Records;
|
using Orchard.ContentManagement.Records;
|
||||||
using Orchard.Data.Conventions;
|
using Orchard.Data.Conventions;
|
||||||
|
using Orchard.Data.Migration.Records;
|
||||||
using Orchard.Environment.ShellBuilders.Models;
|
using Orchard.Environment.ShellBuilders.Models;
|
||||||
|
|
||||||
namespace Orchard.Data.Providers {
|
namespace Orchard.Data.Providers {
|
||||||
@@ -22,12 +23,15 @@ namespace Orchard.Data.Providers {
|
|||||||
|
|
||||||
return Fluently.Configure()
|
return Fluently.Configure()
|
||||||
.Database(database)
|
.Database(database)
|
||||||
.Mappings(m => m.AutoMappings.Add(persistenceModel))
|
.Mappings(m => {
|
||||||
|
m.AutoMappings.Add(persistenceModel);
|
||||||
|
m.FluentMappings.Add(typeof (DataMigrationRecordMap));
|
||||||
|
})
|
||||||
.BuildConfiguration();
|
.BuildConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AutoPersistenceModel CreatePersistenceModel(IEnumerable<RecordBlueprint> recordDescriptors) {
|
public static AutoPersistenceModel CreatePersistenceModel(IEnumerable<RecordBlueprint> recordDescriptors) {
|
||||||
return AutoMap.Source(new TypeSource(recordDescriptors))
|
return AutoMap.Source(new TypeSource(recordDescriptors.Where(x => x.Type != typeof(DataMigrationRecord))))
|
||||||
// Ensure that namespaces of types are never auto-imported, so that
|
// Ensure that namespaces of types are never auto-imported, so that
|
||||||
// identical type names from different namespaces can be mapped without ambiguity
|
// identical type names from different namespaces can be mapped without ambiguity
|
||||||
.Conventions.Setup(x => x.Add(AutoImport.Never()))
|
.Conventions.Setup(x => x.Add(AutoImport.Never()))
|
||||||
|
|||||||
Reference in New Issue
Block a user