Database Migrations
You can migrate easily between Hiqlite and Postgres, or just between different instances of the same database.
Let's say you started out by evaluating Rauthy with the default Hiqlite and a single instance deployment. Later on, you want to migrate to Postgres for whatever reason. Or you started with Postgres and yuo want to reduce your memory footprint by switching to Hiqlite. All of this is easily possible.
Solution: MIGRATE_DB_FROM
If you set the MIGRATE_DB_FROM
in Rauthy's config, it will perform a migration at the next restart.
The way it works is the following:
- At startup, have a look if
MIGRATE_DB_FROM
is configured - If yes, then connect to the given database
- At the same time, connect to the database specified via
HIQLITE
andDATABASE_URL
- Overwrite all existing data in the target database with the data from the
MIGRATE_DB_FROM
source - Close the connection to
MIGRATE_DB_FROM
- Start normal operation
MIGRATE_DB_FROM
overwrites any data in the target database! Be very careful with this option.
If you do not remove the MIGRATE_DB_FROM
after the migration has been done, it will overwrite the target again with
the next restart of the application. Remove the config variable immediately after the migration has finished.
any version below 0.27.0: if you want to migrate to a different database, for instance from SQLite to Postgres, you need to switch to the correct Rauthy image as well.