1 Reply Latest reply on Jun 2, 2011 2:10 AM by _spoboyle

    autoupdate including local DB

    _spoboyle Level 4

      I will be implementing an autoupdate feature for my application shortly, however before I start I would also like the option of being able to update my database without losing any data.

       

      does anyone have any suggestions on how i might go about this or know of any reference material i could go through

       

      This is an AIR application written in Flex 4

       

      cheers

        • 1. Re: autoupdate including local DB
          _spoboyle Level 4

          for anyone else looking I found this

           

          http://stackoverflow.com/questions/550662/database-schema-updates

           

          using this suggested answer

           

          In the case of SQLite, you can make use of the user_version pragma to track the version of the database.  To get the version:

          PRAGMA user_version

          To set the version:

          PRAGMA user_version = 5

          I then keep each group of updates in an SQL file (that's embedded in  the app) and run the updates needed to get up to the most recent  version:

          Select Case currentUserVersion
          Case 1
           
          // Upgrade to version 2
          Case 2
           
          // Upgrade to version 3
          Case etc...
          End Select

          This allows the app to update itself to the most recent version regardless of the current version of the DB.

           

          However Adobe AIR does not support PRAGMA so I replaced that section with a Version Table

           

          not particularly elegant but it works