Migrating to a new SQLInstance¶
Status: Beta
We believe that migration works as intended, but it needs a broader audience to be battle-tested properly. Please report any issues to the #nais channel on Slack.
This guide describes how to migrate your PostgreSQL database to a new SQLInstance.
Preparations¶
Danger
During migration, you can't make structural database (DDL) changes (changing structure of tables, adding or removing tables, etc.) to your database. Check with your team to avoid any problems during the migration.
- Make sure to have the latest version of the nais CLI installed.
- Decide on a new name for the new SQLInstance. It must be different from the current SQLInstance name.
- naisdevice connected.
- Access to the nais cluster where the application is running.
Setting up the migration¶
- Select the correct kubernetes context and namespace
-
Run the setup command and follow the prompts
-
Check that the replication is up to date by checking the URL you got from the setup command. This may take some time, depending on how much data needs to be transferred.
Promoting the new SQLInstance¶
Warning
Promoting the new SQLInstance will cause downtime for your application. Before proceeding, decide on a time when your application can have downtime to perform the promotion.
-
Run the promote command and follow the instructions
-
Check that the application is running as expected, and that all data is available in the new SQLInstance.
- If everything is working as expected, you can proceed to the next step. If something is not working, and you need to roll back, go to the rollback section.
Finalizing the migration¶
Warning
This will delete the old SQLInstance and all data in it. Make sure you have verified that all data is available in the new SQLInstance before proceeding.
There is no rollback option after this point.
-
Run the finalize command
Rolling back the migration¶
If you decide to not go through with the migration, you can roll back to the old SQLInstance at any point (unless you have run finalize).
-
Run the rollback command