Hey, I can't see any easy way to version the DB Schema. Lets say I have a production version running, but in development I want to add a new column to a DB.
What I want to happen, is that I can define this in some sort of config or code somewhere, and then I wish that when I PR into my staging branch, I can have my CI/CD migrate the added column to the staging instance of that database within AppWrite.
Then when I PR to main branch, same thing but change the DB to take that new column.
Of course, in this example it may be simple to do it manually, but I want to remove all manual steps from deployment, and the scenario won't always be this trivial of course.
Is there a current method to do this? Is it just using the server SDK, pulilng the DB schema yourself manually, comparing to the desired schema and making the changes with the server SDK? Or is there something more concrete to help handle this already in existance?
For now, the most common approach is to use a script-based scheme, as you've suggested.
Also, it's good to know that Appwrite supports fetching (init collections) and deploying collection data using Appwrite CLI.
To test it, you can just run these commands after you've logged in.
appwrite login
appwrite init project
appwrite init databases
appwrite init collections
Than, you can deploy them in a different instances / projects
appwrite deploy collections
Check more about it here: https://appwrite.io/docs/tooling/command-line/commands#examples
Hmm, so taking a breif look at the CLI stuff you linked to (thank you!), I could version control the appwrite.json file, and ensure that before PRing from dev to staging that the appwrite.json file has been init'ed correctly with my DB schema, then in my CI/CD, deploy said schema from the appwrite.json file to the staging instance & project?
Ah no, becuase it will overwrite the DB data
Yes. Exactly
Just one thing, I'm not sure about updating an existing one in your production environment, as I've never tried it so it would be best to just test
It shouldn't delete existing data
It seems to suggest that here.
Good to know π
So only for staging and testing
So a good way would be a mix
I'm early in project, I don't have any prod environment right now so loss of data right this minute is fine, can't make any mistakes that cost me - but I am looking to build something out that won't lose my data of course - but testing stuff and playing about now is all good at least π
Recommended threads
- Database backups are not really working
As you can see, backups almost never work and this is repeated behaviour for a long time already. I have the same issue across different databases and different...
- Problem with getting rows from related t...
Hi, I migrated the Appwrite SDK to 1.8.0 and the package in my Flutter app to version ^20.3.2. I noticed one thing is different. Previously, when I got a JSON r...
- Update string attribute
Hi, Unsure if weβre able to use newKey when updating string attribute over node.js server api call to change an attribute name instead of having to create a ne...