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 the 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, Staging and Custom 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 all the environments.
Switch 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.
Custom environments
Appsmith provides two environments by default: Production and Staging. However, if you want to create and manage your own environments, follow these steps:
On the applications home page, click the Menu icon (three dots) in the workspace where you want to create a custom environment.
Select Environments from the menu dropdown.
Click the + Create new button and create a new environment.
Once you've successfully created a Custom environment, you can modify roles and configure the settings by clicking on the edit icon.
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
feature
branch. 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
master
branch.
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.