jean

    jean

    1 year ago
    I’m using sqldelight in my multiplateform package. I want to add a new table to my existing database. Should I create a migration file 
    1.sqm
      and have the
    CREATE
    statement there? What about the requests I want to make on that table, should they be in the same migration file?
    k

    KamilH

    1 year ago
    You should have
    CREATE TABLE
    in your
    .sq
    file (for new users) and put there all of the “requests” to this table. At the same time you should create
    1.sqm
    file that contains only
    CREATE TABLE
    statement (for current users) that is exactly the same as in
    .sq
    file
    You can easily test it by overwriting old version of the app with the new one that have only new
    .sq
    file. It should crash at the startup. Then you can add
    1.sqm
    file and try it again and see if it fixed a problem 🙂
    jean

    jean

    1 year ago
    I did this with small twist, I had to use
    IF NOT EXISTS
    in the
    sqm
    file otherwise the IDE complains the table already exists. Thanks 🙂
    k

    KamilH

    1 year ago
    Interesting, I’ve never had to do it. Thanks for the info 🙂