Restoring can be a bit tricky, if there are any saved row ids (“link” columns). The existing row ids won’t be valid anymore, and will have to be translated. The catch is, there’s no way to tell what the new row id will be; you actually have to create the corresponding record, then ask for its id.
This has to be done as a two-phase process: first, create the new records, without saving any old row ids into them, and record both the old and new row ids of each record; then, using that old-to-new-id translation table, fill in the missing row ids.
It’s also possible to store row ids in non-link columns, e.g., as strings in Text or SimpleObject columns. Anvil’s database schema knows nothing of these cross-references. If you have them (I do), then you’ll need to note, separately from Anvil’s schema, each place where the old ids can be found, and handle those cases in a similar manner.
In practice, one is often “restoring” data into an existing database, i.e, where there already is data. This opens its own can of worms, as this could come from any number of scenarios. How much of the existing data (in the receiving database) needs to be overwritten, or deleted? How do you establish a correspondence, if necessary, between existing and incoming records? If data within a SimpleObject cell (column in row) changes, can it be copied all-or-nothing, or does the cell value need to be selectively updated?
Answers will vary, case by case. And that will dictate the “restore” code we have to write.
I’m starting to think that we need something like Git for our app’s data, as well as for its code.