Database Migrations

Database migrations allow you to update or roll back your Forge database schema to match the requirements of different Forge versions. This is essential for upgrades, downgrades, and maintaining compatibility.

Getting Help

To see all available migration commands and options, run:

forge migrations --help

Applying Migrations

Apply All Pending Migrations

To apply all available migrations and bring your database up to date:

forge migrate

Apply Migrations Up to a Specific Version

To migrate your database schema up to a specific version, use:

forge migrate --apply-to <version>
  • <version>: The target migration version (e.g., 2.15 or 2.14.4).

Example:

forge migrate --apply-to 2.15.1

Rolling Back Migrations

To undo migrations and roll back your database schema to a previous version:

forge migrate --undo-to <version>
  • <version>: The migration version you want to roll back to (e.g., 2.13 or 2.14.4).

Example:

forge migrate --undo-to 2.13

Troubleshooting

  • Always back up your database before applying or rolling back migrations.
  • If you encounter errors, check the logs for details and ensure your CLI version matches your Forge server version.