@@ -5,6 +5,7 @@ import 'package:test/test.dart';
5
5
6
6
import 'utils/native_test_utils.dart' ;
7
7
import 'utils/migration_fixtures.dart' as fixtures;
8
+ import 'utils/fix_035_fixtures.dart' as fix035;
8
9
import 'utils/schema.dart' ;
9
10
10
11
void main () {
@@ -175,5 +176,40 @@ void main() {
175
176
'${fixtures .expectedState [3 ]!.replaceAll (RegExp (r';INSERT INTO ps_migration.*' ), '' ).trim ()}\n ${fixtures .schemaDown3 .trim ()}' ;
176
177
expect (schema, equals (expected));
177
178
});
179
+
180
+ test ('migrate from 5 with broken data' , () async {
181
+ var tableSchema = {
182
+ 'tables' : [
183
+ {
184
+ 'name' : 'lists' ,
185
+ 'columns' : [
186
+ {'name' : 'description' , 'type' : 'TEXT' }
187
+ ]
188
+ },
189
+ {
190
+ 'name' : 'todos' ,
191
+ 'columns' : [
192
+ {'name' : 'description' , 'type' : 'TEXT' }
193
+ ]
194
+ }
195
+ ]
196
+ };
197
+ db.select ('select powersync_init()' );
198
+ db.select (
199
+ 'select powersync_replace_schema(?)' , [jsonEncode (tableSchema)]);
200
+
201
+ db.select ('select powersync_test_migration(5)' );
202
+ db.execute (fix035.dataBroken);
203
+
204
+ db.select ('select powersync_init()' );
205
+ final data = getData (db);
206
+ expect (data, equals (fix035.dataMigrated.trim ()));
207
+
208
+ db.select ('insert into powersync_operations(op, data) values(?, ?)' ,
209
+ ['sync_local' , '' ]);
210
+
211
+ final data2 = getData (db);
212
+ expect (data2, equals (fix035.dataFixed.trim ()));
213
+ });
178
214
});
179
215
}
0 commit comments