This post is a bit long. I’m trying to develop and document a workflow that seperates my Dev Anvil app, local dev environment and Anvil prod app. I thought I had figured it out (thanks to this forum), but I have hit a snag with Data tables (see below).
Workflow
My development workflow consists of 3 phases: Setup, Daily dev, Deployment. It handles versioning code for these different phases of development. It also handles separation of Data tables
My system uses 2 Anvil apps: DEV and PROD. The DEV version can be published for testing. So one could speak of 3 code versions.
It is based on information found here: Best Version Control Options The code versioning is handled by Git.
Setup
- Create app Test_App
- Rename it to Test_App-DEV
- Git clone the app to local dev env:
git clone ssh://theuser@anvil.works:2222/XXXXXXML4XKGY4I.git Test_App_DEV
- Anvil clone app. This cloning also clones the tables and their contents, but not the git history.
- Rename it to Test_App-PROD
- If there are any tables that should be shared, this is the moment to fix those. (MIGHT be wrong; see below)
- Check dependencies (need to use dev or prod version of those?).
- Re-enable the uplink
- Add a git remote to the Anvil Prod app
git remote add PROD ssh://theuser@anvil.works:2222/X2KKKKKKVGGYYAJ3D.git
- Force push to the Prod git repo. This copies the version history.
git push -f PROD
Daily development
- Make changes to Anvil DEV app or in local dev env. Git push and pull to sync between the two.
- Publish the Anvil DEV to let other people test the app (I don’t bother putting this under version control).
Deployment
- Manually sync data tables structure between Anvil DEV and PROD. (See below)
- App secrets should be copied manually.
- Sync dev env to PROD:
git push -f PROD
The problem
This procedure seems to do the trick for the code. However I noticed that data tables did not need upgrading. Then I noticed that the data tables were not copied but that the PROD app referenced the tables of the DEV app. That was NOT intended.
Then I had a look in anvil.yaml file (see below). I noticed that it contained the database schema. That’s probably fine, but it also contains a table_id.
Of course when the code is synced through git the table_id will reference the DEV app’s table(!). That’s not good.
Any suggestions on how to deal with DEV/PROD versions of data tables? TIA
And feedback on the workflow above is also welcome. Especially scrutiny of the git commands would be useful (because I don’t really know what I’m doing).
allow_embedding: false
package_name: Test_App_DEV
db_schema:
- name: First
id: 101836
python_name: first
columns:
0RnQeY0d0ME=:
name: year
type: number
admin_ui: {order: 2, width: 200}
PHt8GqjlmXo=:
name: name
type: string
admin_ui: {order: 1, width: 200}
kwGgKW0vlhI=:
name: id
type: string
admin_ui: {order: 0, width: 200}
r8Ow+KBAJcc=:
name: firstname
type: string
admin_ui: {order: 3, width: 200}
access: {python_name: first, app_id: X227SXPVGGYYAJ3D, server: full, client: search,
table_mapping_name: null, table_mapping_id: null, table_id: 101836}
- name: Other
id: 101879
python_name: other
columns:
1pODDKJPXhs=:
name: blabla
type: string
admin_ui: {order: 0, width: 200}
access: {python_name: other, app_id: X227SXPVGGYYAJ3D, server: full, client: none,
table_mapping_name: null, table_mapping_id: null, table_id: 101879}
name: Test App DEV
startup_form: Form1
renamed: true
runtime_options: {version: 2, client_version: '3', server_version: python3-full}
services:
- source: /runtime/services/tables.yml
client_config: {}
server_config: {auto_create_missing_columns: false}