OK, we have now seen the real world troubles associated with trying to take an existing application and preparing it to be synchronized to CloudKit. In short, it takes some work. If your app is using simple integer primary keys then you have to perform a multi-step process to update all of those IDs to be globally unique identifiers, such as a UUID. And if you have any tables that don’t have a primary key at all, which can be common with join tables, then you have to migrate them to add a primary key.
It’s honestly a lot of work to do these kinds of migrations, and a bit scary since your user’s data is at risk. One small typo and you run the risk of corrupting their data. And so that’s why we also designed a tool that specifically aids in this kind of migration. You can simply provide a list of your tables that you want to migrate, and the tool takes care of analyzing the current schema to perform the multi-step migration process of changing primary keys to UUIDs and adding primary keys to tables that don’t have them. It even takes care to restore any indices or triggers after the migration is done.
But we’ve done all of this work to prepare our app for synchronization and we haven’t actually gotten to sync our data yet! But that’s ok, because on Point-Free we don’t shy away from showing our views the gritty, dark underbelly of app development. These are the kinds of problems we are faced every day, and we don’t all have the benefit of constantly starting with beautiful greenfield projects.
And with our bit of prep work done, we are now ready to actually install a sync engine into our application and unleash the true powers of SQLiteData.
Let’s take a look.