0

I have C++ application (Linux) which uses sqlite3 db through APIs. Currently DB is shipped along with binaries in RPM. This DB has all required tables already. My application does not try to change any schema while running. Now I have to support db schema upgrades for next versions as schema might change going forward. Any idea how can I achieve this?

ND1125
  • 31
  • 2
  • 7

1 Answers1

0

Alembic can definitely do what you want but seeing as your application is in C++ and not python, maintaining all the declarative models of your tables in python would likely not be worth the effort. Seeing as you only use sqlite I would suggest writing the SQL update statements by hand and then taking a leaf out of alembics book and creating a version table with one entry - the current database version.

When your app starts up check the current db version and run your migration scripts in order until you have migrated the database to the latest version.

PS: Do yourself a favor and also write downgrade scripts. These will be handy if you ever need to rollback for whatever reason

Ciaran Liedeman
  • 779
  • 5
  • 13