# Migrations

> **Info:**
Migrations run from **Editor > Migrations** only. The old plugin's files have to be in the server's plugins folder. It does not have to be running.

## Sources

| Plugin | Reads | Notes |
| ------ | ----- | ----- |
| ExcellentEconomy, CoinsEngine | Every currency, from its SQLite or MySQL database | Each old currency is mapped on its own. |
| EssentialsX | The balance in every userdata file | NPC accounts are left out. |
| CMI | The balance in its SQLite database | Not tested on a live install yet. |
| PlayerPoints | The points, from its SQLite or MySQL database | |
| TokenManager | The tokens, from its data file or MySQL | Not tested on a live install yet. |
| VotingPlugin | The vote points, from its SQLite database or MySQL | Not tested on a live install yet. |
| UltraEconomy | Every currency, from its MySQL database. Hand and bank are added together | Asks for the MySQL connection first. File storage cannot be read: move it to MySQL with its own transfer command. Not tested on a live install yet. |
| RedisEconomy | Every currency, straight from Redis | Asks for the Redis connection first, filled in from its config when found. Not tested on a live install yet. |
| Vault | The economy registered with Vault right now, for every player this server knows | The old plugin has to be running. Not tested on a live install yet. |

<figure><img src="../.gitbook/assets/migrations/sources.png" alt="" width="563"><figcaption><p>Migrations (Migrate from EssentialsX)</p></figcaption></figure>

Each source shows whether its files were found on this server. Player names are imported too, so the players can be paid by name straight away. Players are always matched by UUID, so a Bedrock player and a Java player whose names only differ by the Bedrock prefix keep their own balances.

## Connection

UltraEconomy and RedisEconomy keep their data on a database server, so clicking them opens a connection screen first: host, port, database, user, password, SSL and, for Redis, the key prefix (its cluster id). Read the Balances connects and reads without changing anything. The values are kept until the editor closes.

## Vault Copy

Reads balances through the other economy plugin registered with Vault, for every player in this plugin's player list and every player who ever joined the server. Players without an account there are left out. When two accounts share a name, only the one seen most recently is read, because some economy plugins look balances up by name. Balances are read in chunks off the server thread; if the other plugin refuses that, the rest is read on the server thread.

<figure><img src="../.gitbook/assets/migrations/vault-copy.png" alt="" width="563"><figcaption><p>Migrations (Migrate from Vault)</p></figcaption></figure>

## Mapping

After reading the old plugin, every currency it has is listed with how many players hold it and the total. Pick which of your currencies each one goes to, or leave it out.

<figure><img src="../.gitbook/assets/migrations/mapping.png" alt="" width="563"><figcaption><p>Import (Money Balances)</p></figcaption></figure>

## Import Mode

| Mode | Does |
| ---- | ---- |
| Add | Adds each imported balance to what the player has here. Players without an account start at the imported balance. |
| Replace | Sets each player's balance to the imported one, whatever they had here before. |

<figure><img src="../.gitbook/assets/migrations/import-mode.png" alt="" width="563"><figcaption><p>Import (Import Mode)</p></figcaption></figure>

Both are safe to run twice. Replace sets the same balances again, and Add remembers which players it already credited from that source and skips them.

## Start Import

Imports the picked balances after a confirmation, then reports how many were imported, skipped and failed, with the reasons.

<figure><img src="../.gitbook/assets/migrations/start-import.png" alt="" width="563"><figcaption><p>Import (Start Import)</p></figcaption></figure>

| Left out | Why |
| -------- | --- |
| No valid player UUID, or a balance that is not a number | The entry cannot be read. |
| A balance below zero | Balances here cannot be negative. |
| A zero balance with nothing to change | There is nothing to import. |
| A balance over the currency's maximum | The [maximum balance](../main-features/currencies/edit-currency.md#maximum-balance) is kept. |
| NPC, town and server accounts | They are not players. |
| Players without an account in the old economy | Vault copy only. |
| Accounts that share a name with a newer one | Vault copy only. |

Every imported balance is logged in the [transaction log](transaction-log.md) as an import.

Source: https://www.phoenixplugins.com/docs/phoenix-currencies/features/migrations