feat:回退版本报错的问题

This commit is contained in:
dzc committed 2026-09-22 16:08:42 +08:00
1 parent 383ea2ad4b
commit 2d6603dfd5
10 files changed
+424 -241

No files matched your search

+30
View File
@@ -143,4 +143,34 @@ void main() {
throwsA(isA<DatabaseException>()),
);
});
test('13到14迁移补指令列且列已存在时可重入', () async {
final database =
await databaseFactoryFfi.openDatabase(inMemoryDatabasePath);
addTearDown(database.close);
await database.execute('''
CREATE TABLE print_history (
id INTEGER PRIMARY KEY AUTOINCREMENT,
orderId TEXT NOT NULL,
serviceOrderId TEXT NOT NULL,
servicePrintId TEXT NOT NULL,
invoiceUrl TEXT NOT NULL,
status TEXT NOT NULL,
printTime TEXT,
syncTime TEXT,
createTime TEXT NOT NULL
)
''');
await DatabaseMigration.migration13To14.migrate(database);
final columns = await database.rawQuery('PRAGMA table_info(print_history)');
expect(
columns.map((column) => column['name']),
contains('printCmd'),
);
// 外部存储旧库可能已带该列(中间态构建建库、降级重建),重复迁移不得抛 duplicate column。
await DatabaseMigration.migration13To14.migrate(database);
});
}