File tree Expand file tree Collapse file tree 4 files changed +11
-11
lines changed
CoreDataMigration-ExampleTests/CoreData
CoreDataMigration-Example/CoreData Expand file tree Collapse file tree 4 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -72,9 +72,9 @@ class CoreDataManager {
72
72
fatalError ( " persistentContainer was not set up properly " )
73
73
}
74
74
75
- if migrator. requiresMigration ( storeURL : storeURL) {
75
+ if migrator. requiresMigration ( at : storeURL) {
76
76
DispatchQueue . global ( qos: . userInitiated) . async {
77
- self . migrator. migrateStore ( storeURL : storeURL)
77
+ self . migrator. migrateStore ( at : storeURL)
78
78
79
79
DispatchQueue . main. async {
80
80
completion ( )
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ class CoreDataMigrator {
28
28
29
29
// MARK: - Check
30
30
31
- func requiresMigration( storeURL: URL , currentMigrationModel: CoreDataMigrationModel = CoreDataMigrationModel . current) -> Bool {
31
+ func requiresMigration( at storeURL: URL , currentMigrationModel: CoreDataMigrationModel = CoreDataMigrationModel . current) -> Bool {
32
32
guard let metadata = NSPersistentStoreCoordinator . metadata ( at: storeURL) else {
33
33
return false
34
34
}
@@ -38,7 +38,7 @@ class CoreDataMigrator {
38
38
39
39
// MARK: - Migration
40
40
41
- func migrateStore( storeURL: URL ) {
41
+ func migrateStore( at storeURL: URL ) {
42
42
migrateStore ( from: storeURL, to: storeURL, targetVersion: CoreDataMigrationModel . current)
43
43
}
44
44
@@ -47,7 +47,7 @@ class CoreDataMigrator {
47
47
fatalError ( " unknown store version at URL \( sourceURL) " )
48
48
}
49
49
50
- forceWALCheckpointing ( storeURL : sourceURL)
50
+ forceWALCheckpointingForStore ( at : sourceURL)
51
51
52
52
var currentURL = sourceURL
53
53
let migrationSteps = sourceMigrationModel. migrationSteps ( to: targetVersion)
@@ -79,7 +79,7 @@ class CoreDataMigrator {
79
79
80
80
// MARK: - WAL
81
81
82
- func forceWALCheckpointing ( storeURL: URL ) {
82
+ func forceWALCheckpointingForStore ( at storeURL: URL ) {
83
83
guard let metadata = NSPersistentStoreCoordinator . metadata ( at: storeURL) else {
84
84
return
85
85
}
Original file line number Diff line number Diff line change @@ -20,13 +20,13 @@ class CoreDataManagerTests: XCTestCase {
20
20
21
21
var requiresMigrationToBeReturned = false
22
22
23
- override func requiresMigration( storeURL : URL , currentMigrationModel: CoreDataMigrationModel = CoreDataMigrationModel . current) -> Bool {
23
+ override func requiresMigration( at : URL , currentMigrationModel: CoreDataMigrationModel = CoreDataMigrationModel . current) -> Bool {
24
24
requiresMigrationWasCalled = true
25
25
26
26
return requiresMigrationToBeReturned
27
27
}
28
28
29
- override func migrateStore( storeURL : URL ) {
29
+ override func migrateStore( at : URL ) {
30
30
migrateStoreWasCalled = true
31
31
}
32
32
}
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ class CoreDataMigratorTests: XCTestCase {
115
115
func test_requiresMigration_true( ) {
116
116
let storeURL = CoreDataMigratorTests . moveFileFromBundleToTmpDirectory ( fileName: " CoreDataMigration_Example_1.sqlite " )
117
117
118
- let requiresMigration = migrator. requiresMigration ( storeURL : storeURL)
118
+ let requiresMigration = migrator. requiresMigration ( at : storeURL)
119
119
120
120
XCTAssertTrue ( requiresMigration)
121
121
}
@@ -124,7 +124,7 @@ class CoreDataMigratorTests: XCTestCase {
124
124
let storeURL = CoreDataMigratorTests . moveFileFromBundleToTmpDirectory ( fileName: " CoreDataMigration_Example_3.sqlite " )
125
125
let migrationModel = CoreDataMigrationModel ( version: . version3)
126
126
127
- let requiresMigration = migrator. requiresMigration ( storeURL : storeURL, currentMigrationModel: migrationModel)
127
+ let requiresMigration = migrator. requiresMigration ( at : storeURL, currentMigrationModel: migrationModel)
128
128
129
129
XCTAssertFalse ( requiresMigration)
130
130
}
@@ -137,7 +137,7 @@ class CoreDataMigratorTests: XCTestCase {
137
137
138
138
let sizeBeforeCheckPointing = try ! FileManager . default. attributesOfItem ( atPath: storeURL. path) [ FileAttributeKey . size] as! NSNumber
139
139
140
- migrator. forceWALCheckpointing ( storeURL : storeURL)
140
+ migrator. forceWALCheckpointingForStore ( at : storeURL)
141
141
142
142
let sizeAfterCheckPointing = try ! FileManager . default. attributesOfItem ( atPath: storeURL. path) [ FileAttributeKey . size] as! NSNumber
143
143
You can’t perform that action at this time.
0 commit comments