https://kotlinlang.org logo
a

Andrew O Hart

04/06/2022, 10:54 AM
Hey, I created a new .sq file, which has CREATE TABLE LastModificationDate(lastModificationDate TEXT NOT NULL); This causes a crash when testing against our production app as it says LastModificationDate. no such table: LastModificationDate: , while compiling: SELECT * FROM LastModificationDate I'm not sure how I am meant to migrate this new table, in the .sqm file I don't think I'm altering anything as its actually just a new table, so should I be creating the table in the .sqm? If so, how does that work with the functions that exist in LastModificationDate such as insert/get/delete
a

alec

04/06/2022, 12:28 PM
you need to create the table in a migration file. You dont need to create queries in a migration file
a

Andrew O Hart

04/06/2022, 1:40 PM
@alec just saw your message, thanks. So I created a 1.sqm file with CREATE TABLE LastModificationDate(lastModificationDate TEXT NOT NULL); Then in my LastModificationDate.sq, i just have the queries such as insert, get, delete?
If the case, LastModificationDate.sq it shows 'no table found with name LastModificationDate'
a

alec

04/06/2022, 1:42 PM
you need the create table in both .sq and .sqm
a

Andrew O Hart

04/06/2022, 1:52 PM
Thanks. I actually just tried rebuild it with only CREATE TABLE in 1.sqm, and just the queries in the LastModificationDate.sq and it seemed to build correctly.
When i try it by creating a table in both .sq and .sqm, i get
'Table already defined with name LastModificationDate'
a

alec

04/06/2022, 1:57 PM
i see, you have
deriveSchemaFromMigrations = true
a

Andrew O Hart

04/06/2022, 2:31 PM
No I don't, should I add it?
Sorry, I actually do have it added, forgot that I added it earlier
Another thing I noticed was all my DAO related tests for Android were failing, it was fixed by moving all my other CREATE TABLE in the other .sq files to the .sqm file, is this a normal part of the process?
Adding them to the .sqm file makes the tests pass but the actual app crashes on migration
2 Views