Javascript ORM API: Handle model updates in different versions

R Ruben Ruben 3 years ago
1 3 0

Hi,

We are soon releasing a new version of one of our apps. This new version includes some model changes, and when testing update scenarios, it seems that unless we remove the previous version or do a complete DB reset (manually) the app won't work correctly.

I remember that within the Ruby API it was possible to add model versions to the definition of the model itself, but I don't see the same functionality in the Javascript version. How should we handle this so no user intervention is required when updating the app?

Thanks,

Rubén Torrero

Please register or login to post a reply

3 Replies

R Ruben Ruben

I figured it out: in the documentation for the Ruby API, there is at the end information about a rhoconfig.txt variable:
     app_db_version

When this is set to a value higher than the previous build, it will reset the database on the first start.

J Jon Tara

I'd guess that "not available in Javascript" actually means "not available in Javascript!"

Try a little Ruby! It's not that scary! A migration is a good place to start.

And application.rb is also a good place to start, because there are many cool things you can do with it, that I don't think you can do with JS.

For example, what if you want to send a user an email, and they can click on a link and it will open your app to a a specific item? ("Your order has been shipped! Click here to view details in our app..."). You can do that in application.rb.

Migrations are NECESSARY if you use a fixed schema.

Migrations are A CONVENIENCE if you use PropertyBag. It allows you to massage the database once so that you don't have to write a bunch of conditional code all over the place to deal with changes that have been made in the past.

I think your app doesn't work correctly because of assumptions that some code in your application make about what will be found in the tables. Patch it up at the migration.

I haven't done a migration in Rhodes, but have in Ruby on Rails. It's a common need.

K Kutir Mobility

Hi Ruben,
Have you tried 'set' method to define version?
     model.set("schema_version",'1.0')

Visnupriya R
Kutir Mobility

CONTACT
Can’t find what you’re looking for?