|
106 | 106 | } |
107 | 107 | } |
108 | 108 |
|
| 109 | + @available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) |
| 110 | + @Test func addColumn_OldRecordsSyncToNewSchema() async throws { |
| 111 | + let remindersList = RemindersList(id: 1, title: "Personal") |
| 112 | + try await userDatabase.userWrite { db in |
| 113 | + try db.seed { |
| 114 | + remindersList |
| 115 | + } |
| 116 | + } |
| 117 | + try await syncEngine.processPendingRecordZoneChanges(scope: .private) |
| 118 | + |
| 119 | + syncEngine.stop() |
| 120 | + |
| 121 | + try await userDatabase.userWrite { db in |
| 122 | + try #sql( |
| 123 | + """ |
| 124 | + ALTER TABLE "remindersLists" |
| 125 | + ADD COLUMN "position" INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT 0 |
| 126 | + """ |
| 127 | + ) |
| 128 | + .execute(db) |
| 129 | + } |
| 130 | + |
| 131 | + let relaunchedSyncEngine = try await SyncEngine( |
| 132 | + container: syncEngine.container, |
| 133 | + userDatabase: syncEngine.userDatabase, |
| 134 | + tables: syncEngine.tables |
| 135 | + .filter { $0.base != Reminder.self && $0.base != RemindersList.self } |
| 136 | + + [ |
| 137 | + SynchronizedTable(for: ReminderWithPosition.self), |
| 138 | + SynchronizedTable(for: RemindersListWithPosition.self), |
| 139 | + ], |
| 140 | + privateTables: syncEngine.privateTables |
| 141 | + ) |
| 142 | + defer { _ = relaunchedSyncEngine } |
| 143 | + } |
| 144 | + |
109 | 145 | @available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) |
110 | 146 | @Test func addAssetToRemindersList() async throws { |
111 | 147 | let personalList = RemindersList(id: 1, title: "Personal") |
|
0 commit comments