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
- It says domain already used but I have d...
I accidentally deleted the project in which I used my domain originally (orexia.app) from name.com. Now I am trying to add it to a different project and it says...
- Is this normal in the self host custom d...
when i try to add custom domain to the project did not see this in 1.8.0 ok when pressed the retry it says "DNS verification failed with resolver 8.8.8.8. Domai...
- No server error on selfhosted appwrite
Please help me, my clients is ask what happen on their data? How can i make it up again?