Environments walkthrough

Understand how to manage environments, switch between environments and promote tasks between environments.
In this guide, we'll create a task in a newly created development environment and then promote it to production. You may want to use a development environment to ensure a new task is working properly, or test changes to an existing task before releasing it to your team.

Create a development environment

Create a dev environment from the Environments page. You'll be able to choose the display name and slug for the environment (you can change these later). Let's choose Development for the display name and dev for the slug.
You can optionally choose a template to base the dev environment on. This will copy all tasks, runbooks, resources, configs and schedules to the newly created environment. Schedules will be paused by default.

Set up a database

We need to create a databse that we want to run this new SQL task against. If you don't already have a database set up, you can create an Airplane Postgres database under the resource settings page.
In this example, we will name the database Demo DB.
On the resource settings page, you can run this query to create a table and insert data into it:
sql
Copied
1
CREATE TABLE accounts (
2
id SERIAL PRIMARY KEY,
3
company_name text,
4
signup_date timestamp with time zone DEFAULT now(),
5
total_dollars integer DEFAULT 0,
6
country text DEFAULT 'USA'::text
7
);
8
9
INSERT INTO accounts (id, company_name, signup_date, total_dollars, country)
10
VALUES
11
(0, 'Future Golf Partners', '2020-03-21 04:48:23.532+00', 1655427, 'Brazil'),
12
(1, 'Amalgamated Star LLC', '2020-07-16 00:40:30.103+00', 43403102, 'Canada'),
13
(2, 'Blue Sky Corp', '2019-04-18 10:14:24.71+00', 1304097, 'France'),
14
(3, 'Yeet Table Inc', '2019-10-01 10:06:39.013+00', 4036934, 'Mexico');

Create a SQL task

Switch to the newly created dev environment by selecting Development in the top left dropdown menu.
Create a SQL task named Environments Demo. You can optionally add a description. Click continue to configure the SQL task.
Let's add the following SQL query in the query configuration setting:
sql
Copied
1
SELECT company_name, total_dollars
2
FROM accounts
3
ORDER BY total_dollars DESC;
Execute the task in your dev environment and ensure the task runs properly. You should see rows of demo data.

Promote the task to production

Now that we've verified the task works properly in Development, it's time to promote the task to our prod environment. Click the triple dot dropdown for the Environments Demo SQL task from either the library or task edit page. From the dropdown, select Promote... and then select Production as the environment to promote to.
Finally, we need to promote the resource configuration to our Production environment so that the newly promoted SQL task can run against the Demo DB. Click the triple dot dropdown for the Demo DB resource via the settings page. From the dropdown, select Promote... and then select Production as the environment to promote to.
We're ready to run the task in the prod environment. Switch to the prod environment by selecting Production in the top left dropdown menu. Run the task in the prod environment and verify that it works correctly.

Additional details

While the examples here involved editing and promoting a task via the UI, you can also edit and promote tasks, runbooks and other entities via the CLI and Deployments. For more information, see Promoting between environments.