Database Migrations
You can migrate easily between SQLite and Postgres, or just between different instances of them.
Let's say you started out by evaluating Rauthy with a SQLite and a single instance deployment. Later on, you want to migrate to a HA setup, which requires you to use a Postgres.
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 in the
DATABASE_URL
- Overwrite all existing data in
DATABASE_URL
with the data from theMIGRATE_DB_FROM
database - Close the connection to
MIGRATE_DB_FROM
- Use the
DATABASE_URL
as the new database and 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.
v0.14 and beyond: 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. Rauthy v0.14 and beyond has different container images for the databases.