Back

CLI usage for duplicating database in test project

  • 0
  • Self Hosted
  • Tools
BobcatProgrammer
10 Oct, 2024, 09:20

In my project I want to test my business logic using unit tests (vitest). To do that efficiently (without mocking full appwrite SDK) I have created a test project on my appwrite instance. To keep databases in sync between dev and test I use appwrite cli. First pulling the dev state:

TypeScript
# Login to server
appwrite login
# Init my dev project
appwrite project init
# Download all config to appwrite.json
appwrite pull all

After that I use appwrite client to get a temporary connection to the test project. I then delete the existing test db and push all collections

TypeScript
appwrite database delete --database-id mydb
appwrite push collections --all -- force

My expectation would be that this does NOT modify my appwrite.json when I only push. And the appwrite client command should also be only temporary. However my appwrite.json now has the test project in projectId and projectName and no longer the devproject. This now means that I need to run appwrite loginagain if I want to make changes to dev or pull changes of others.

Is this inteded behaviour? Can this be made configurable? Would help with scripting/automation

TL;DR
Developers want to use CLI to duplicate a database in a test project efficiently. They are facing issues with `appwrite.json` file being modified when pushing collections. They are looking for a way to avoid changing project IDs between dev and test projects. Solution: The behavior of the CLI changing the `appwrite.json` file is intended. To avoid this, developers can consider creating separate configuration files for dev and test projects. This can help maintain distinct project configurations without overwriting them during operations.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more