Updating scripts (new solution)

Discussion created by jjfcpa on Sep 15, 2014
Latest reply on Sep 15, 2014 by DavidJondreau

First off, this is a very simple solution that I created for my daughter (and granddaughter) to help them with memorization tasks in school. It's just a simple flash card solution.


Created it in a few hours and created a runtime solution and installed it on her computer. Worked great.


So now comes the task of updating it with new features while they are busy entering data for their memorization projects. I've come up with the following and just wondering if this is the standard procedure. Perhaps there is no standard, but this is what I came up with.


1. I created an Export Data script that will export the data from the existing solutions to CSV files. Only two tables - Categories and Cards - and these are exported to exportCategories.csv and exportCards.csv. All data is exported EXCEPT for primary keys.


2. I then put on a new solution and they run an Import Data script that will then import the data from the two exported CSV files.


I do have one question that has bothered me since I started adding the Import and Export options.


The cards table is linked to the categories table by a child - parent key. Conceivably, the primary key for the Categories table will change when the exported categories data is imported into the new solution. This could then break the parent-child relationship between the categories and the cards. What I did is create a field in the categories table called pkOLD and then populate it with the primary key of each record BEFORE exporting the data.


Then after importing, I just loop through the categories and grab the old key and the new key and then do a REPLACE FIELD command in the cards table and replace the foreign key with the new key if it currently has the old key in it.


I hope this is clear and if not please let me know.


What I couldn't tell is if it is standard practice to import the original keys into the new solution, but it seemed like that could lead to all kinds of problems if you were careful, especially if the user were to enter data in the new solution BEFORE they did the import of the exported data.


Any advice would be greatly appreciated. I tried searching for this topic in the forums but couldn't really find anything that offered much clarificaiton.