Migrating from Pact Broker
If you have previously used the open source Pact Broker with a PostgreSQL database it is possible to migrate that data to Pactflow, keeping everything and making it available in Pactflow. The migration process uses the existing Pact Broker database. Database migrations are then performed to add additional tables and data used for Pactflow features.
Migration is only supported for a Pact Broker running a PostgreSQL database.
Single Pact Broker instance
- Re-use your existing Pact Broker environment variables, updating the names to read
PACT_BROKER_*. A full list of the Pactflow environment variables can be found here.
It is crucial that all
PACT_BROKER_DATABASE_* environment variables are renamed to
PACTFLOW_DATABASE_* while their
values remain the same. This is because your existing Pact Broker database will be used, and updated for use with Pactflow as part of the process.
If you previously set the environment variables
PACT_BROKER_AUTO_MIGRATE_DB_DATAremove these and replace them with a new environment variable named
PACTFLOW_DATABASE_AUTO_MIGRATE. Set its value to
true. This environment variable will allow your existing database to be updated with the required structures and data to support Pactflow, and maintain any existing data.
You do not need to add the new variable if you did not previously set
When the Pactflow instance starts up the migrations will run automatically. The migrations can be run manually instead if needed. See details here
Multiple Pact Broker instances
It is not currently possible to combine multiple Pact Broker databases into a single database for use with Pactflow. Instead one Pact Broker database can be used in the migration, and the others ran in parallel with the new Pactflow instance until sufficient data is transferred. The Pactflow instance must contain all production versions of all services used in the contract test before it can safely take over all 'can-i-deploy' checks.
The recommended steps are as follows:
- Select one of the Pact Broker databases to update and use going forwards.
- Follow instructions above to set up Pactflow using this database.
- The Pact Broker instances that was used in the upgrade process and be decommissioned, as the database and its contents are now available in Pactflow.
- Run the Pactflow instance and any other existing Pact Broker instances in parallel. Duplicate the pact publication and pact verification tasks in your pipeline. The duplicated task should use the new Pactflow instance details. In this way all new data can gradually added to Pactflow while ensuring
can-i-deploystill has access to production versions of all services.
- Continue to run Pactflow and Pact Brokers in parallel. Once the Pactflow instance contains all the
productionversions for all the services used in the contract tests the old Pact Broker instances can be safely decommissioned. This will allow Pactflow to be the sole source of data for 'can-i-deploy'
- Clean up any code and API calls that were used to run Pactflow and existing Pact Brokers in parallel. The pact publication and pact verification steps in your pipeline that used the old Pact Brokers can be removed.