mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-03-25 10:51:31 +01:00
added tool to convert existing NSManagedObjectModels to the new CoreStoreSchema
This commit is contained in:
@@ -31,6 +31,78 @@ import Foundation
|
||||
|
||||
public protocol MigrationMappingProvider {
|
||||
|
||||
associatedtype SourceType: DynamicObject
|
||||
associatedtype DestinationType: DynamicObject
|
||||
associatedtype SourceSchema: DynamicSchema
|
||||
associatedtype DestinationSchema: DynamicSchema
|
||||
|
||||
var sourceSchema: SourceSchema { get }
|
||||
var destinationSchema: DestinationSchema { get }
|
||||
|
||||
init(source: SourceSchema, destination: DestinationSchema)
|
||||
|
||||
// func migrate(
|
||||
// from oldObject: SourceType,
|
||||
// to newObject: DestinationType,
|
||||
// transaction: UnsafeDataTransaction
|
||||
// )
|
||||
//
|
||||
// func forEachPropertyMapping(
|
||||
// from oldObject: SourceType,
|
||||
// to newObject: DestinationType,
|
||||
// removed: (_ keyPath: KeyPath) -> Void,
|
||||
// added: (_ keyPath: KeyPath) -> Void,
|
||||
// transformed: (_ keyPath: KeyPath) -> Void,
|
||||
// copied: (_ keyPath: KeyPath) -> Void
|
||||
// )
|
||||
}
|
||||
|
||||
public extension MigrationMappingProvider {
|
||||
|
||||
// func migrate(from oldObject: SourceType, to newObject: DestinationType, transaction: UnsafeDataTransaction) {
|
||||
//
|
||||
//
|
||||
// }
|
||||
//
|
||||
// func forEachPropertyMapping(from oldObject: SourceType, to newObject: DestinationType, removed: (_ keyPath: KeyPath) -> Void, added: (_ keyPath: KeyPath) -> Void, transformed: (_ keyPath: KeyPath) -> Void) {
|
||||
//
|
||||
// let oldAttributes = oldObject.cs_toRaw().entity.attributesByName
|
||||
// let newAttributes = newObject.cs_toRaw().entity.attributesByName
|
||||
// let oldAttributeKeys = Set(oldAttributes.keys)
|
||||
// let newAttributeKeys = Set(newAttributes.keys)
|
||||
// for keyPath in
|
||||
// }
|
||||
}
|
||||
|
||||
public extension MigrationMappingProvider {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// MARK: - UnsafeMigrationProxyObject
|
||||
|
||||
public final class UnsafeMigrationProxyObject {
|
||||
|
||||
public subscript(kvcKey: KeyPath) -> CoreDataNativeType? {
|
||||
|
||||
get {
|
||||
|
||||
return self.rawObject.cs_accessValueForKVCKey(kvcKey)
|
||||
}
|
||||
set {
|
||||
|
||||
self.rawObject.cs_setValue(newValue, forKVCKey: kvcKey)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MARK: Internal
|
||||
|
||||
internal init(_ rawObject: NSManagedObject) {
|
||||
|
||||
self.rawObject = rawObject
|
||||
}
|
||||
|
||||
|
||||
// MARK: Private
|
||||
|
||||
private let rawObject: NSManagedObject
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user