Be advised that this can break client creation if done incorrectly!
Please follow this guide with caution and make sure you know what you are doing.
This guide provides practical steps to merge multiple Ory Hydra Postgres
database instances with different
system.secret values into one instance with
$SECRETS_SYSTEM is an environmental variable, that is
used to encrypt Ory Hydras database.
If you are looking for information on how to change (rotate) the
system.secret, please refer to the
Secrets and Key Rotation Guide.
First we take all the system.secret keys and add them to the target instance environment variables like so:
Then we run the following pg_dump command against the databases we need to migrate:
Take extra care with the following manual edits!
Then we open each of the dump files and manually edit
entirely set to the value
(SQL keyword) to make it
follow the sequence in the target DB correctly.
We delete the last line of the dump, since it sets the value of the primary key
sequence to the number of the donor database.
So we need to delete this line. This step is crucial!
If you don't remove it, it will potentially break client creation, since it
will reset the sequence of
hydra_clients.pk to what it was in the source DB
After that the final step is to import the data like so:
And that did it, we successfully merged multiple Hydra instances with different
system.secret into one instance with one