---
title: "Upgrade"
description: "The steps to upgrade from an earlier version of the package."
version: "5.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.

# Upgrade

## Upgrade from 4.x to 5.0

Version 5.0.0 changes some behavior of version 4. To upgrade:

1. Use the new names of the configuration keys, and `--export-data-from-tables` in place of `--exportDataFromTables`. The old names give a PHP deprecation notice. Version 6.0 removes them. See [Application options](/5.0/configuration#application-options).
2. Choose the migrations log with `log-in-db`. Version 6.0 makes the database log the default. To move to the database log, run `import-log`. See [Migrations log](/5.0/log).
3. Examine your scripts. A CLI option now wins over the configuration for each setting, also `--descr`.
4. MySQL: the connection uses the `utf8mb4` character set. In version 4, it used `utf8`. To keep `utf8`, set `charset` in the `database` section. See [Database options](/5.0/configuration#database-options).
5. Generate again the versions that did not run yet, if their files do not have all the data of the table. See [Files from version 4.0.1 or earlier](/5.0/migration-files#files-from-version-401-or-earlier).
6. Make sure that your migration files have the comments of the columns. The morph now compares the comment. A column with no comment in the file loses the comment of the live column.
7. Examine your incremental versions. `run` and `export` can stop with an error for two versions with the same old order number. See [Order of the versions](/5.0/versions#order-of-the-versions).
8. Remove `--dry` from `run`. In version 4, `run --dry` ran the migrations. Now it stops with an error.
9. Examine the boolean keys of the configuration that have a text value. A text such as `"false"` or `"off"` is now `false`. In version 4, it was `true`.

:::warning[WARNING]
The morph of version 5 reads the `CURRENT_TIMESTAMP` defaults and the `ON UPDATE CURRENT_TIMESTAMP` of the live columns, and compares them with the file. The `generate` of version 4.0.1 and earlier left them out of the files. When an old file runs, the morph removes them from the live columns. This happens each time that the version runs, also on a new database, where all the versions run. Before you run the migrations, add the missing values to the old files, for example `'default' => "CURRENT_TIMESTAMP"` or `'onUpdate' => "CURRENT_TIMESTAMP"`. See [Files from version 4.0.1 or earlier](/5.0/migration-files#files-from-version-401-or-earlier).
:::

The first `generate` after the update creates a version, because the format of the generated files changed. The old files run as before. See [Old migration files](/5.0/migration-files#old-migration-files).

If your code uses the classes of the package, also examine these changes:

* `Config::$logInDb` is `null` when the configuration does not set `log-in-db`. In version 4, it was `false`.
* `Generate::getEntity()` gives only the header of the file: the `declare` line, the namespace and the `use` lines. Use `Generate::getCode()` for the text of the file.

## Upgrade from 3.x to 4.0

Version 4.0.0 removes the dependency on the Phalcon extension. To upgrade:

1. Use PHP 8.2 or later.
2. Change your PHP configuration file to return an array. See [Create the configuration file](/5.0/quick-start#create-the-configuration-file).
3. If you call `Migrations::run()` in your code, use `Config::fromArray()` for the `config` option. See [Usage example](/5.0/php-api).
4. Update your migration files with the `migrate-files` command.

First, see the files that the command changes:

```
vendor/bin/phalcon-migrations migrate-files --migrations=db/migrations --dry-run
```

Then change the files:

```
vendor/bin/phalcon-migrations migrate-files --migrations=db/migrations
```

`--dry-run=false` is the same as no `--dry-run`: the command changes the files.

The `--migrations` option is required. The path is relative to the current directory. The command reads all the `.php` files in the directory and its subdirectories, and replaces these lines:

| Old line                    | New line                               |
|-----------------------------|----------------------------------------|
| `use Phalcon\Db\Column;`    | `use Phalcon\Migrations\Db\Column;`    |
| `use Phalcon\Db\Index;`     | `use Phalcon\Migrations\Db\Index;`     |
| `use Phalcon\Db\Reference;` | `use Phalcon\Migrations\Db\Reference;` |

:::warning[WARNING]
The command replaces only these exact lines. If a file refers to the `Phalcon\Db` classes in a different way, for example with a fully qualified class name or a grouped `use` statement, change the file manually. If a file uses integer column types instead of the `Column::TYPE_*` constants, change them to the constants.
:::

Migration files that you do not update continue to work if the `Phalcon\Db` classes are available, for example from the Phalcon extension. The package converts the `Phalcon\Db\Column`, `Phalcon\Db\Index` and `Phalcon\Db\Reference` objects when the migration runs.

Source: https://migrations.phalcon.io/5.0/upgrade/index.mdx
