Closed yixiu30 closed 1 year ago
Hey @yixiu30
Sorry, it's not clear what problem you hit with Floor.
Basically the database version declares in @Database(version: <your_actual_version>)
annotation.
Migration which should be applied in the Migration(<from_version>, <to_version>, ....)
object
and the migrations are executed in order, one after the other
1 -> 2, 2 -> 3, 3 -> 4
if it's declared, of course
Here is more info https://pinchbv.github.io/floor/migrations/
and you lost the space between englishname
and TEXT
I'm not sure if this is an issue or just a sample code
thank you very much! but i find anthor problem,you see this
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: DatabaseException(Error Domain=FMDatabase Code=1 "table chatrecord has no column named nameEn" UserInfo={NSLocalizedDescription=table chatrecord has no column named nameEn}) sql 'INSERT OR ABORT INTO chatrecord (chatListId, head_url, name, content, type, time, groupId, chatId, sendId, staffId, origingUrl, compressUrl, width, height, picture_local, title, fileType, filesize, filelocal, fileurl, isDownload, chatUuid, file_id, system, audioOpenEd, audioRecord, audioClick, dailyReportId, dailyReportType, isDailyReport, briefId, addContent, href, dialogHeight, upDateText, nameEn) VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' args [https://test.xiamenjwzz.com:9999/portalfile/userPi..., weijiwo, , 1, 2023-01-03 16:43:20.945, 4872098147432661014, 225739, 4804247830982033430, 2fb135026aae410d81330a4162a6983d, https://files-1304239070.cos.ap-nanjing.myqcloud.c..., https://files-1304239070.cos.ap-nanjing.myqcloud.c..., 0, 0, , , , , , , 0, cb293d40-ba08-44e3-a8a2-36fac2f9e392, d5ffd44b596845268acb84e6ba20f7f2, 0, 0, , 0, , , 0, , report, , , , ]
@yixiu30
Please check your database version in @Database
annotation
in your case, to execute the migration code above it should be 8
no answer for a while
In the test process, I added the field nickname for the first time. I added two more fields, chinesename and englishname, as required. But at this time, if I upgrade the database one version at a time, there is no problem, such as versions three to four. However, if I upgrade the database from the online version two to the latest version four, I will not report an error this is the example from three to four version, // create migration final migration1to2 = Migration(3, 4, (database) { database.execute('ALTER TABLE person ADD COLUMN chinesename TEXT'); database.execute('ALTER TABLE person ADD COLUMN englishnameTEXT'); }); final database = await $FloorAppDatabase .databaseBuilder('app_database.db') .addMigrations([migration1to2]) .build();