mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +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 virtual int Id { get; set; }
|
||||
public virtual string DataMigrationClass { 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 Orchard.ContentManagement.Records;
|
||||
using Orchard.Data.Conventions;
|
||||
using Orchard.Data.Migration.Records;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
|
||||
namespace Orchard.Data.Providers {
|
||||
@@ -22,12 +23,15 @@ namespace Orchard.Data.Providers {
|
||||
|
||||
return Fluently.Configure()
|
||||
.Database(database)
|
||||
.Mappings(m => m.AutoMappings.Add(persistenceModel))
|
||||
.Mappings(m => {
|
||||
m.AutoMappings.Add(persistenceModel);
|
||||
m.FluentMappings.Add(typeof (DataMigrationRecordMap));
|
||||
})
|
||||
.BuildConfiguration();
|
||||
}
|
||||
|
||||
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
|
||||
// identical type names from different namespaces can be mapped without ambiguity
|
||||
.Conventions.Setup(x => x.Add(AutoImport.Never()))
|
||||
|
Reference in New Issue
Block a user