开发者

What is the behavior of an application when upgdraded at appstore

I wanted to know something which is very disturbing for me. i.e.

Lets say I have an App. which is in the Appstore and running fine. This App. has a local database with lets say 5 tables.

I update this App. and add 2 more new tables, which makes it a total of 7.

When the previous app version users will upgrade to the newer version. Will the database be updated also for the previous version users ?

开发者_C百科

If yes ? then will the previous data will be removed.

If not then the code will obviously make some crashes as it is going to need the new things which are not replaced.

Waiting for your precious comments.


It will all depend on your database. If you are using CoreData, you can migrate the users data into the new database and structures. All the information for your data model is stored in the .xcdatamodel class for your project. It isn't bundled into your code the way other files are.

The part you would need to look into is the Model Versioning Identifier. Here you will be able to increment your MOM, Managed Object Model.

You can also migrate the data over as well. I would review Apple's documentation on CoreData with focus on versioning and migration. Good luck.

Apple Core Data Versioning


If the database is based on coredata then you will need to use .

But if you are using sqlite DB

Then you can save the version number of your app into your db and whenever database is called(with new installation/upgrade), compare the version against the expected version If new version > older version then change the schema (this is needed if you would have changed the schema of your database) with using SQL ALTER statements and update the app version number. so whenever user is going to update or fresh installation, it will check the new version with your older version,

if it differ then 
    update schema, 
and if its same 
    no need to make any changes.

If you would not have made any schema related changes (for example adding new column..) then you do not need to worry, user will not lose the data.


The contents of the documents directory is left unchanged. The contents of the .app bundle is completely replaced with the new version.

If you store your database in the documents directory and it is modified by the application, you will need to perform some migration to upgrade to the new version. If it's just a read-only database, you can copy over it with the new database.


It depends on where database is placed. All files in application bundle will be replaced. Files in Documents directory will remain intact unless you overwrite them... Where do you store your database?

What i consider a good approach is to place database in bundle then on first run copy it to documents directory so that you gain RW access. In your updated application you can check if database exists in Documents read it and update tables to new version, if not then just copy file from bundle to new location.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜