From 7dad9406e4f77e9606c8219938dddb014cc662e2 Mon Sep 17 00:00:00 2001 From: kenji Date: Wed, 12 Jul 2023 10:38:18 +0700 Subject: [PATCH] fix: no need drop the `evalution` table for migration --- Bucketeer.xcodeproj/xcshareddata/xcschemes/Example.xcscheme | 4 ++-- .../Sources/Internal/Database/Migration/Migration2to3.swift | 5 +---- BucketeerTests/MigrationTests.swift | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/Bucketeer.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/Bucketeer.xcodeproj/xcshareddata/xcschemes/Example.xcscheme index 8d2d7d3d..19fdffe4 100644 --- a/Bucketeer.xcodeproj/xcshareddata/xcschemes/Example.xcscheme +++ b/Bucketeer.xcodeproj/xcshareddata/xcschemes/Example.xcscheme @@ -53,12 +53,12 @@ diff --git a/Bucketeer/Sources/Internal/Database/Migration/Migration2to3.swift b/Bucketeer/Sources/Internal/Database/Migration/Migration2to3.swift index 3828227a..daa4357d 100644 --- a/Bucketeer/Sources/Internal/Database/Migration/Migration2to3.swift +++ b/Bucketeer/Sources/Internal/Database/Migration/Migration2to3.swift @@ -6,9 +6,6 @@ final class Migration2to3: Migration { } func migration() throws { - try db.exec(query: "DROP TABLE IF EXISTS Evaluations") - let evaluationTable = SQLite.Table(entity: EvaluationEntity()) - let evaluationSql = evaluationTable.sqlToCreate() - try db.exec(query: evaluationSql) + try db.exec(query: "DELETE FROM Evaluations") } } diff --git a/BucketeerTests/MigrationTests.swift b/BucketeerTests/MigrationTests.swift index e44effed..6f1f19b2 100644 --- a/BucketeerTests/MigrationTests.swift +++ b/BucketeerTests/MigrationTests.swift @@ -58,7 +58,7 @@ AND (name NOT LIKE 'sqlite_%' AND name NOT LIKE 'ios_%') .mock1 ] try dao.put(userId: "user1", evaluations: mocks) - // Run migrate , it will drop `evaluations` table + // Run migrate , it will delete all data from `evaluations` table try Migration2to3(db: db).migration() let sql = """ SELECT id FROM Evaluations