From af6a315eb4bd732ae5cee6f9106fc96b8c3b1172 Mon Sep 17 00:00:00 2001 From: masakih Date: Mon, 30 Oct 2017 22:26:34 +0900 Subject: [PATCH] =?utf8?q?=E3=83=87=E3=83=BC=E3=82=BF=E3=83=95=E3=82=A1?= =?utf8?q?=E3=82=A4=E3=83=AB=E3=82=92=E4=BD=9C=E6=88=90=E3=81=97=E7=9B=B4?= =?utf8?q?=E3=81=99=E3=83=9E=E3=82=A4=E3=82=B0=E3=83=AC=E3=83=BC=E3=82=B7?= =?utf8?q?=E3=83=A7=E3=83=B3=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=AE=E7=AF=84?= =?utf8?q?=E5=9B=B2=E3=82=92=E5=BA=83=E3=81=92=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- KCD/MOCGenerator.swift | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/KCD/MOCGenerator.swift b/KCD/MOCGenerator.swift index 6959a689..97b718d7 100644 --- a/KCD/MOCGenerator.swift +++ b/KCD/MOCGenerator.swift @@ -58,6 +58,20 @@ final class MOCGenerator { return model } + private func isMigrationError(_ code: Int) -> Bool { + return [ + NSPersistentStoreIncompatibleVersionHashError, + NSMigrationError, + NSMigrationConstraintViolationError, + NSMigrationCancelledError, + NSMigrationMissingSourceModelError, + NSMigrationMissingMappingModelError, + NSMigrationManagerSourceStoreError, + NSMigrationManagerDestinationStoreError, + NSEntityMigrationPolicyError + ].contains(code) + } + private func createCoordinator(_ model: NSManagedObjectModel) throws -> NSPersistentStoreCoordinator { if !checkDirectory(ApplicationDirecrories.support) { @@ -73,7 +87,7 @@ final class MOCGenerator { // Data Modelが更新されていたらストアファイルを削除してもう一度 if error.domain == NSCocoaErrorDomain, - (error.code == 134130 || error.code == 134110), + isMigrationError(error.code), config.tryRemake { removeDataFile() -- 2.11.0