---
title: "Versions"
description: "Incremental versions and timestamp based versions."
version: "6.0"
---

> Documentation Index
> Fetch the complete documentation index at: https://migrations.phalcon.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Versions

## Incremental versions

By default, `generate` creates incremental versions. The first version is `1.0.0`. Each new version adds one to the last number: `1.0.1`, `1.0.2` and so on.

To set the version name, use `--version`:

```
vendor/bin/phalcon-migrations generate --version=2.0.0
```

A version with fewer than three parts gets zeros. For example, `--version=1.1` creates the version `1.1.0`.

If the version already exists, the command stops with an error. To overwrite the files of the existing version, add `--force`.

A version with another name can be the same version, for example `1.0.0.0` and `1.0.0` (see [Order of the versions](#order-of-the-versions)). `generate --version=1.0.0.0` next to `1.0.0` stops with the error `Version 1.0.0 already exists`. With `--force`, it overwrites the files of `1.0.0`.

### Order of the versions

The package compares incremental versions part by part, as numbers:

* `1.0.9 < 1.0.10 < 1.0.11 < 1.1.0`
* `1.0.0 < 1.0.0.1`
* `1.0.0` and `1.0.0.0` are the same version. A missing part is `0`.

`run` and `export` stop with an error, before they change the database, in these conditions:

* Two versions are the same version. If they are in two migrations directories, use one configuration for each set of migrations, each with its own log (`--log-table` or `--log-path`). If they are in one directory, for example `1.0.0` and `1.0.0.0`, remove or rename one of the two version directories.
* Two versions have the same old order number, for example `1.0.10` and `1.1.0`, and old files make the order unsafe. This is true when both versions have old files. It is also true when only one of the two versions is in the log, and the other version has old files. In version 4.0.1 and earlier, only one of the two versions ran. The error names the two versions. It also names the version that is not in the log, if there is one: that version did not run on this database. Remove the version, or generate it again.

The old order number is the version stamp of the old class names, `X * 100 + Y * 10 + Z`. See [Old migration files](/6.0/migration-files#old-migration-files).

## Timestamp based migrations

Using this approach is useful when more than one developer is participating in the database structure management.

* To generate a timestamp based version, use the `--ts-based` option, or `ts-based` in the config file. To add a description to the version, also set the `--descr` option, or `descr` in the config file.
* To run, list or export timestamp based versions, use `'ts-based' => true` in the config file, or the `--ts-based` option.

A description with no `ts-based` stops `generate` with an error, and `generate` writes no files:

```
The option descr needs ts-based: a description is a part of a timestamped version only. Set ts-based, or remove descr.
```

The description has lowercase letters and digits, in groups with one underscore (`_`) between them, for example `create_users`. Other characters, two underscores together, or an underscore at the start or at the end stop `generate` with an error. For example:

```
vendor/bin/phalcon-migrations generate --ts-based --descr=create_users
```

The command creates a version directory with a name like this:

```sh
* 1582539287636860_create_users
```

The name is the current Unix time in microseconds, then `_`, then the description.

Migrations will be executed from oldest to newest.

:::info[NOTE]
Whenever migrations are run, the application scans all available migrations and their status irrespective of their "age". If one or more were not executed in a previous run, they will be executed in the next run.
:::

Source: https://migrations.phalcon.io/6.0/versions/index.mdx
