Add or edit data tables outside production

I recently made change to a dev version of my app which included adding a new data table. After pushing the changes to production (hosted on Anvil) I noticed the data tables were not updated.

Steps to reproduce the issue:

  1. Update code and added data table using Anvil editor to dev version (hosted on Anvil).
  2. Pulled changes to integration version of app located on local machine.
  3. Pushed changes to production app hosted on Anvil.
  4. Click ‘Restore this version’ in production app within Anvil editor.
  5. All code changes are present however new app table is missing.

Is this the expected behaviour? If so do you have recommendations for how to effectively manage data tables across different development versions of an app?

Thanks

There is currently no automatic migration of data table changes from the dev to prod app. You have to recreate the data table changes yourself on prod.

There’s a cool utility to help you identify those changes. You may need to modify it for your use, but it gives you a good starting point. You’ll need to have both your dev and prod repositories cloned on your local machine to identify data table differences.

I use this utility with my dev/prod split and it works well.

3 Likes

Thanks for sharing @jshaffstall.

So for each remote version of the app we need to replicate data table changes via the editor. Local versions should inherit any changes via the schema in the anvil.yaml file. Is that correct?

Is there anything additional you do to manage your anvil.yaml files? I assume each version of the app will generate different IDs for each table you create so these will be out of synch.

Each app does generate different IDs for each table.

If by “local versions” you mean the local git repos, then they do contain the most recent version of the table schemas in anvil.yaml.

If by “local versions” you mean a version running on the open source Anvil server, there’s an auto-migration flag you can set when you run the server. That might take care of table changes, but I haven’t used the open source server so can’t swear to that.

Mostly I just leave anvil.yaml alone, and try to avoid actually changing anything in the production version of the app via the editor (as that then requires a force push from the dev repo). The fact that the editor picks up the app name from anvil.yaml is annoying, but just something you learn to ignore in the editor.