Setup Multiple Datasource Environments
This page shows how to set up and manage multiple datasource environments for your application. For more details see datasource environments.
Configure an environment
This section shows how to configure staging and production environments in Appsmith.
Click the Explorer tab on the Entity Explorer to the screen's left.
Click the + icon next to Datasources and select your datasource.
SaaS integrations such as Google Sheets, HubSpot, Twilio, and Airtable do not support datasource environments.
Configure production and staging datasource connection parameters in the respective tabs. For a complete description of the connection parameters, see the Reference guide for your datasource.
Test and save the configurations for both production and staging environments.
Select the environment on the bottom left corner of the screen to configure the application to execute queries in the staging or production environments. Switching between environments in the Edit mode does not affect the deployed version of the app, as the production environment is always used for the deployed version.
Developers can switch between staging and production environments in the Edit mode. In addition, users with the necessary permissions can also switch to the staging environment configuration when accessing the app in View mode. For more information on permissions, you can refer to the Granular Access Control..
With this, you can create queries and switch between environments. As you toggle between environments, the queries would automatically use the selected environment.
Use Git with Datasource Environments
Using Git with environment configurations allows you to connect your application to version control and work on different branches, ensuring that changes made during development do not affect the production environment. This approach enables you to thoroughly test changes on staging data before merging them into the master branch for deployment.
You can create a new branch for each feature you're working on and commit changes to that branch as you make progress. Once a feature is stable and ready for deployment, you can merge it into the master branch.
To use environments with Git, you can follow these steps:
- If you haven't done it already, connect your application to Git.
- Connect to a datasource and configure the Staging and Production environments.
- In the Staging environment, create and switch to a
featurebranch. See Setup Branches to create a branch.
- Use the Staging environment to make edits to your application so that you can test the changes without affecting production data.
- Once you have tested your changes and are ready to deploy to production, commit your changes and merge into the
When you merge changes into the master branch, the production data remains unchanged, ensuring that end-users continue to view the same data they did before the changes were made.