Coredata migration is really needed? - core-data

I have a SQLite database with two columns it is bundled in the app. There is no write or save interaction in the database, it is fixed and read only. I read some documents and tutorials about the lightweight/manual migration all make it clear that you have to save the user data when migrating, that is not my case I don't need to save user data, I will deploy a new app version with a new database. I want to add two new attributes to my database and use in the app. Why I have to migrate? Why can't I just delete the old three files of SQLite database and add the new one and use the new attributes as needed. So I tried and did not work, anyone here to give me the steps to make the app to recognize the new database?

Actually the way to delete the SQL database files is the right way.
But you have to do that before the Core Data stack is going to be initialized.

Related

How to transfer data from old database to new modified database in django?

I have old django project and new django project. I created dump file from database of old django. And also I made changes in tables and created new tables.
Now I want to load that dump file to my new django app. I am facing errors when I firstly migrate then restore data or firstly restore then migrate..
When I do migration first, it says tables already exist.
When I do restore first , it says django.db.utils.ProgrammingError: relation "django_content_type" already exists
I use migrate --fake error goes but new tables are not created in database.
I spent 3-4 days but could not succeed.
Please, help me if you can.
PS: my database is postgresql
This is not straightforward and will need some manual interventions and it depends on what do you want to do in the future
If the tables that already exist in the database have a stable design and won't be changed or you can do the changes manually using SQL statements then set managed = False to the models' meta, this will make Django skip making migrations for those models
If you want to keep the power of migration in the new project for all models then this will more complex
Delete all your migrations
You need to make your models equivalent to your database, you can set managed=False for new models like Users
Run python manage.py makemigrations, this will create the structure of the initial database.
Fake running the migrations python manage.py migrate --fake
Dump the records of django_migrations table
Create a new empty migration (with --empty) and add the SQL statements of the django_migrations table to it using migrations.RunSQL()
now fake again so you skip that new migration.
Now you are ready to use migrations as usual.
When installing new database, you will just need to run python manage.py migrate

Table Replication and Synchronization in AZURE

I am pretty new to AZURE cloud and stuck at a place where I want to repplicate 1 table into another database with same schema and table name.
By replication I mean, the new table in another database should automatically synced with the original table. I can do this using the elastic table, but the queries are taking way too long and some time getting timed out, so I am thinking of having a local table in another database instead of elastic table, but I am not sure how I can do this in AZURE ?
Note: Both database resided on same DB server
Any example, links will be helpful
Thanks
To achieve this you can use a DACPAC (Data-Tier Package) a data tier package can be created in Visual Studio or extracted from an existing database. They contain the database creation scripts and manage your deltas for you. More information can be found here. For information about how to build and deploy a DACPAC using both VS and extracted from a database see this answer

Kofax project and batch class

Kofax Capture Version 9
I have an existing Project and Batch class that works, built previously by Kofax engineer.
What I need to do is change the script in the project to use a new DB connection. This seemed simple enough.
Using project builder I copied the existing project, altered the script and saved the project. Using Capture Administration I copied the existing batch class and then used Synchronize Kofax Transformation Project and pointed to the new project. All this seemed to work without error.
However the script being executed is the original not my altered one, any guidance would be great.
Make sure you are creating a new batch after publishing your change. The batch class class update function works in very limited scenarios, so I don't generally recommend it.
There are many ways that a database connection might be handled in script. Usually I would expect that a function at the project script level handles the connection and is called from any sub class, but you might want to check any sub classes to make sure they aren't using locally defined connection strings.
Even if you are making a connection in script (which you've now changed), you might also be using product features that use databases. Open Project Settings and check the Databases tab.
If there are relational databases listed, simply change as needed.
If you are actually using "Remote Fuzzy" databases then these might be using Kofax Search and Matching Server which connects to a relational database to build the fuzzy db. In this case you would need to use KSMS Admin to change the connection on the KSMS server.
If you are using "Local Fuzzy" databases then the info is based on the content of a text file. You might have some external process (possibly Markview) that dumps this text file from a database.

Did a successful Core Data migration but the existing store was deleted

I have a CoreData store managed with MagicalRecord. I did a successful migratiion, but lost the data in the newly created store. This is what I have:
salonbookV1.0 is the original xcdatamodel for the initial store. I added only new attributes to an existing entity, and the mappingmodel looks like this: (a partial image).
Let me elaborate on what I did...
created the xcdatamodeld folder with both xcdatamodel's in it
marked the salonbookV1.0 as the current version and ran the app creating some entries
stopped the app, and marked salonbookV1.5 as the current version and ran the app
data which was entered previously was gone! (apparently the migration did not occur)?
The migration was accomplished; I know that because I can use the new attributes. However, the existing CD store was deleted. I have read all I can on MR, and there is only one method that deals with migration; MR does the rest without any coding from me.
So the question remains: why is the existing store being deleted?
I don't know about MR but in "normal" Core Data you have to set the NSMigratePersistentStoresAutomaticallyOption to the persistent store, otherwise it will not migrate your existing data to the new store version.

Some default objects of core data entities

Here I have some entities in core data, for example, "Account",
and I wish that, when user enter my app for the first time, there is some thing in Account,
to make it more clear, maybe I should say I want to give some default managed-objects for an entity so that they will be there when the app is just installed.
How can I achieve this?
Thanks a lot!
I have a similar requirement for an app I'm working on. I am using a sqlite persistence store for my data, so I basically want to pre-populate that table with the data for my default entities.
To do this, I have created a separate project in my Xcode workspace that shares the same data model with my app. In this separate project I write the code I need to insert entities into the table, and to store the file in a well-known place on my Mac.
Then, I copy the sqlite file that my initializer app has created into the resources directory for my "real" app. As part of the startup for that app, I wrote a small bit of code that copies the default DB from the resources to my app's documents folder if a copy doesn't already exist there.
The end result is this: I can run my initializer app to populate the default data as I need to. I then copy the file into my real app, so when the app is first run there is a default copy of that DB ready to go.

Resources