Friday, 21 December 2018

Sqlite table and database migrations on a Published app?

I have developed an android app in react-native and expo. I have also published the app on google play.

Now, I have made some modifications on my SQLite DB tables locally.

Suppose, before the schema of a table was like this:

CREATE TABLE expenditures (id integer primary key, max_amount REAL not null);

And now I would like to change it to this:

CREATE TABLE expenditures (id integer primary key, max_amount TEXT not null);

Is there any way to run a method after a new update/upgrade on a production app (google play store)? That way I can alter the tables only once after the upgrade, and other newly installed users won't be affected by this function. I found two methods on native android:

  1. onCreate: Called for the first time when creation of tables are needed.
  2. onUpgrade: This method is called when database version is upgraded.

But since I have developed my app with react-native and expo, I can't use the above methods. Although I have found onUpgrade in the expo code, I am not sure how to use this feature in expo.

Or is there any better way to handle database migrations on a published app in react-native and expo?



from Sqlite table and database migrations on a Published app?

No comments:

Post a Comment