# Understanding virtual environment versions

## Introduction

A virtual environment `version` is where you configure which process flow components (connector instances, caches, scripts, etc.) to replace when flows are run for this environment. During its lifecycle, a single virtual environment version can move through three statuses:

* Draft
* Deployed
* Inactive

## The lifecycle of a virtual environment version

Each new `draft` version increments the version number. During its lifetime, this version moves through status changes, but the version number is retained. This cycle is illustrated below:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2F15ov8dU17K6ufGIeq0wM%2Fve%20version%20lifecycle%204.png?alt=media&#x26;token=42def073-176e-4622-8112-48f1ace31d26" alt=""><figcaption></figcaption></figure>

From here you can see:

* When a virtual environment is first created, a `draft` version is added automatically.&#x20;
* When the `draft` version becomes `deployed`, a new `draft` version is generated from the previous one, automatically.
* When the latest `draft` is updated and deployed, the previously `deployed` version becomes `inactive`.
* A maximum of [five versions](#what-happens-when-my-virtual-environment-version-exceeds-five-versions) can exist for a given virtual environment at any time. When this limit is reached, the oldest `inactive` version is overwritten with each subsequent version deployment.

## What happens when my virtual environment version exceeds five versions?

As noted above, a given virtual environment can have a maximum of five versions at any time. When this limit is reached, the oldest `inactive` version is overwritten with each subsequent version deployment. The table below steps through a repeated lifecycle so you can see how this works:

<table><thead><tr><th width="231.34765625">Action</th><th>Draft version</th><th>Deployed version</th><th>Inactive version</th></tr></thead><tbody><tr><td>Virtual environment created</td><td>#1</td><td>-</td><td>-</td></tr><tr><td>Draft version deployed</td><td>#2</td><td>#1</td><td>-</td></tr><tr><td>Current draft updated &#x26; deployed</td><td>#3</td><td>#2</td><td>#1</td></tr><tr><td>Current draft updated &#x26; deployed</td><td>#4</td><td>#3</td><td>#1 and #2 </td></tr><tr><td>Current draft updated &#x26; deployed</td><td>#5</td><td>#4</td><td>#1 and #2 and #3</td></tr><tr><td>Current draft updated &#x26; deployed</td><td>#6</td><td>#5</td><td>#2 and #3 and #4</td></tr><tr><td>Current draft updated &#x26; deployed</td><td>#7</td><td>#6</td><td>#3 and #4 and #5</td></tr></tbody></table>

{% hint style="info" %}
You can [delete](https://doc.wearepatchworks.com/product-documentation/virtual-environments/managing-virtual-environments-versions-and-flows/managing-virtual-environment-configuration-versions/deleting-a-virtual-environment-version) `inactive` or  `draft` versions, if required.
{% endhint %}

## Versioning rules for virtual environments

The table below provides more information for each virtual environment status.

<table><thead><tr><th width="140.8359375">Status</th><th width="222.5625">Set when...</th><th>Notes</th></tr></thead><tbody><tr><td><code>Draft</code></td><td><ul><li>A <a href="../creating-a-virtual-environment">new virtual environment is added</a> </li><li>An existing <code>draft</code> version is deployed </li><li>A <code>deployed</code> or <code>inactive</code> version is used to create a draft.</li></ul></td><td><p>Only one <code>draft</code> version can exist for a given virtual environment.<br><br>Only the <code>draft</code> version can be edited. </p><p></p><p>To update the current <code>deployed</code> version or an <code>inactive</code> version, you should <a href="../../../managing-virtual-environments-versions-and-flows/managing-virtual-environment-configuration-versions/updating-a-virtual-environment-version#create-draft-from-version">create a draft version</a> from it first.</p></td></tr><tr><td><code>Deployed</code></td><td><ul><li>The existing <code>draft</code> version is deployed.</li><li>An <code>inactive</code> version is deployed.</li></ul></td><td><p>Only one <code>deployed</code> version is ever associated with a given virtual environment. When a virtual environment is <code>deployed</code>:</p><p></p><ul><li>The deployed configuration is used when any associated flow versions run.</li><li>This virtual environment becomes available for selection when <a href="../deploying-a-single-process-flow-to-a-virtual-environment">deploying process flows</a>.</li><li>This virtual environment becomes available for selection when <a href="../testing-a-process-flow-against-a-virtual-environment">testing a process flow against a virtual environment, using the advanced run option</a>.</li></ul><p>You can't edit a <code>deployed</code> version, however, you can <a href="../../managing-virtual-environments-versions-and-flows/managing-virtual-environment-configuration-versions/updating-a-virtual-environment-version">create a new draft</a> from it.</p></td></tr><tr><td><code>Inactive</code></td><td><ul><li>An updated <code>draft</code> or currently <code>inactive</code> version is deployed</li></ul></td><td><p>Each time a <code>draft</code> or (less commonly) <code>inactive</code> version is deployed, a new <code>inactive</code> version is created from the previously <code>deployed</code> version.</p><p></p><p>If the maximum of five versions is reached for a virtual environment, the oldest inactive version is overwritten with each new deployment.<br><br>You can't edit an <code>inactive</code> version, but you can <a href="../../../managing-virtual-environments-versions-and-flows/managing-virtual-environment-configuration-versions/updating-a-virtual-environment-version#create-draft-from-version">create a draft version</a> from it and go through the lifecycle again. You can also <a href="../deploying-the-configuration-for-a-virtual-environment">deploy</a> an <code>inactive</code> version or <a href="../../managing-virtual-environments-versions-and-flows/managing-virtual-environment-configuration-versions/deleting-a-virtual-environment-version">delete</a> it.</p></td></tr></tbody></table>
