How do you update the database every time there is a fresh install/reinstall?
Looked in the docs, can't find anything - so what ends up happening, if I have changed my models, I will get a SQLlite error upon a fresh update.
Thanks
I think you can use :
Titanium.App.version
It will give you app version(Store it), at the time of initialization of your app check the current version.If it does not matches the one you have stored, just delete and recreate the database.
check out the Documentation here.
Hope it helps.
Related
Good day guys,
I noticed my application deletes database structure and re add new one everytime i Run my application.
The DBset uses DropCreateDatabaseIfModelChanges. I have read about the other options like CreateDatabaseIfNotExist. is there any other option to force it from recreating database?
And also with throwing any exception of error?
I have been able to resolve this by using Code First Migrations
The template comes without database at first. When I launch the application some code must create the db obviously, because I check the appData folder and now it's there.
Can you tell me which part of the code creates it? Thanks. I have long looked at the code and I cannot figure it out.
I think the only answer possible is that entity framework creates the database automatically. But the strange thing is if I remove thee database it does not get recreated, I get an error that says it's missing it.
Now i am using Microsoft Access 2016 and suddenly i can't open one of my tables.Its say "Not a valid bookmark".
After using compact and repair,that table is missing.
I can't export the database,That error is always.I have no idea why.
I was checked other answer and It doesn't make clue.
Please help me.
That's a corruption issue. Running C&R is your only method to get it cleaned up.
So, revert to the latest backup, restore data otherwise somehow, or - if essential and valuable data are lost - contact a paid restore service.
A reputable service can be found here.
Not sure if you made a back up before C&R so whether or not you still have that trouble-table.
Create a brand new db. Import into it everything from the problem db EXCEPT that trouble-table. Sanity check that all this behaves ok.
Create another new db - and import into it only the trouble table. It probably still won't open but it might. If it does - export the data out to excel; create a new table in your other new db; and import the data back in. If it does not open try another C&R with this new db file. If still no joy I think you'll have to create a new table.
You'll want to try and determine how this happened - I rarely see a totally corrupt table. A move to a new edition i.e. 2016 - if it is a big jump such as from 2003 - I have seen where things are less forgiving. Be sure if this is multi user that the db application is split and every user has their own front end file - this is the primary cause of corruption these days.
At the early stages of development, where data retention is no issue and experimental changes to the schema are expected to be numerous, is there a way to avoid migration? Namely, just to dump the database and start over each time.
Everything I try leads to the error: "The model used to open the store is incompatible with the one used to create the store".
Lightweight migration looks do-able, but I'll end up lots of unwanted versions and messy code. I'd also like to experiment with relationships (no wise cracks), but understand I'd need to commit to a heavyweight migration afterwards!
If the solution is to check for the existence of the original database using NSFileManager and delete/remove it if found, could someone please show the swift code with an example name of the original database, and how it can be effectively removed.
I've been trying several suggested solutions, such as dragging a copy of the .xcdatamodeld file onto the desktop, deleting the file in xcode and bringing it back in, but I keep getting the error that the model and store are not the same.
Answered in one line in first comment, but appreciated in reverse proportion.
I received the source for an application from a guy to make a few changes in the app. The data model version was, say, App3. I had to add about 3-4 more data model versions in the process. So the active model version when I sent him was App7
I built the project (it was running properly on my mac)
I sent him the zip and when he ran, he got the error "Can't find model for source store"
I had him create the latest data model again, based on the data model App3 and make it the same as App7 and set it as the current version.
He still has the error and I can't figure out why? Are the intermediate data model version causing issues? Is it required to delete the sqlite file in the application support->iphone simulator folder? I am all over the place with this. Please help!
You need to have both model files and have some sort of versioning in place. The new model that you made will no longer work with his data file unless you specify to Core Data that you want it to update the data.
Versioning isn't that easy, but if your changes are small enough, you might be able to get away with automatic versioning. Read the guide and see:
http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreDataVersioning/Articles/Introduction.html
In my understanding, it will. But really that is not the thing to do if ultimately the versioning is going to happen on existing live apps too.
For the light-weight migration to work, you need to send him all the intermediate versions of the model as well since the migration takes place stage by stage through all versions.
And you have to make sure that you have made no modification (even accidentally) to the base version App3.