upgrade_db.rst 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. Upgrade a database
  2. ==================
  3. For changes to the database schema, we rely on `Alembic <http://alembic.readthedocs.org/>`_.
  4. This allows us to do upgrade and downgrade of schema migration, kind of like
  5. one would do commits in a system like git.
  6. To upgrade the database to the latest version simply run:
  7. ::
  8. alembic upgrade head
  9. .. note:: if pagure's configuration file isn't in ``/etc/pagure/pagure.cfg``
  10. you will have to specify it to alembic using the command: ::
  11. PAGURE_CONFIG=/path/to/pagure.cfg alembic upgrade head
  12. This allow applies for the command specified below.
  13. This may fail for different reasons:
  14. * The change was already made in the database
  15. This can be because the version of the database schema saved is incorrect.
  16. It can be debugged using the following commands:
  17. * Find the current revision: ::
  18. alembic current
  19. * See the entire history: ::
  20. alembic history
  21. Once the revision at which your database should be is found (in the history)
  22. you can declare that your database is at this given revision using: ::
  23. alembic stamp <revision id>
  24. Eventually, if you do not know where your database is or should be, you can
  25. do an iterative process stamping the database for every revision, one by one
  26. trying every time to ``alembic upgrade`` until it works.
  27. * The database used does not support some of the changes
  28. SQLite is handy for development but does not support all the features of a
  29. real database server. Upgrading a SQLite database might therefore not work,
  30. depending on the changes done.
  31. In some cases, if you are using a SQLite database, you will have to destroy
  32. it and create a new one.