Database Schema Upgrade Feasibility for PrivacyIdea 2.21.4 Schema to 3.8.1

Dear PrivacyIdea Community,

I have a much neglected privacyidea application running on version 2.21.4 that I am considering upgrading to v3.8.1.

Can anyone please advise if the database schema upgrade scripts are able to deal with such a large gap between the start(v2.21.4) and target(v3.8.1) db schema versions?

If this is not practical or feasible, I will deploy a new clean v3.8.1 database, a new v3.8.1 application and recreate QR codes for the team.


If you are running privacyIDEA 2.21, then you most probably are running a very extremely old distribution underneath. Maybe you should set up a new one, anyways.

The schema upgrade should™ work.

However, if you have a couple of thousands tokens in your database, the migration could take a while when updating from 2.x to 3.0.

Thanks for replying Cornelius, and for the advice also.

We are currently running privacyIDEA on Red Hat 7 so the underlying distribution is not so old.

Is the databse schema upgrade simply a matter of executing the following command from the new privacyIDEA 3.8.1 application server after amending the db pointer within the pi.cfg file to point to the old 2.21 database server/schema?

privacyidea-schema-upgrade /opt/privacyidea/lib/privacyidea/migrations

The pi.cfg file currently points to the new empty db schema running at version 3.8.1 so repointing it to the old db server should be very straightforward.

Are there any ‘dummy’ or ‘trial’ upgrade runs that can be performed to see if the upgrade is likely to work or fail?

What if the upgrade fails halfway through the process? Will that leave the database corrupt requiring a restore?


I would recomment to do a new 3.8.1/3.9 installation.

Dump the old database and move it to the old installation. Now you have 3.x code with a 2.21 database.

In this case you can run the schema update, without touch your old, existing installation.

Hi Cornelius,

Thanks for the advice. :slight_smile:

We decided to go with a new clean database as we do not have a large number of users.

Our actual deployment included PrivacyIdea at 3.8.1, Python 3.8 and Red Hat on 8.8 and it seems to be working well. :crossed_fingers:

We will try to perform more frequent upgrades in the future and this should ensure that the corresponding schema upgrades are more realistic and less likely to fail or take too long.

We are also considering deploying it as a container as that would simplify things for us.

Anyway, thanks again for your assistance.