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
- Manual install docs are out of sync with...
I looked into the manual install docs issue for Appwrite 1.9.0 and wanted to share the findings, since this seems to need a bigger docs decision. What I found:...
- Migration from Self-Hosted to Cloud seem...
Hello, I'm trying to migrate from my Self-Hosted Appwrite instance to Cloud, and can't figure out what's going wrong. - If I initiate the migration from Cloud...
- custom domain on self host Appwrite
I am having a issue, i am using self host version of appwrite at my custom domain (appwrite.example.com), but when i tried adding a custom domain (project1.exam...