14.2.48. camcops_server.cc_modules.cc_alembic

camcops_server/cc_modules/cc_alembic.py


Copyright (C) 2012-2019 Rudolf Cardinal (rudolf@pobox.com).

This file is part of CamCOPS.

CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <http://www.gnu.org/licenses/>.


Functions to talk to Alembic; specifically, those functions that may be used by users/administrators, such as to upgrade a database.

If you’re a developer and want to create a new database migration, see tools/create_database_migration.py instead.

camcops_server.cc_modules.cc_alembic.downgrade_database_to_revision(revision: str, show_sql_only: bool = False, confirm_downgrade_db: bool = False) → None[source]

Developer option. Takes the database to a specific revision.

Parameters:
  • revision – destination revision
  • show_sql_only – just show the SQL; don’t execute it
  • confirm_downgrade_db – has the user confirmed? Necessary for the (destructive) database operation.
camcops_server.cc_modules.cc_alembic.import_all_models()[source]

Imports all SQLAlchemy models. (This has side effects including setting up the SQLAlchemy metadata properly.)

camcops_server.cc_modules.cc_alembic.upgrade_database_to_head(show_sql_only: bool = False) → None[source]

The primary upgrade method. Modifies the database structure from where it is, stepwise through revisions, to the head revision.

Parameters:show_sql_only – just show the SQL; don’t execute it
camcops_server.cc_modules.cc_alembic.upgrade_database_to_revision(revision: str, show_sql_only: bool = False) → None[source]

Upgrades the database to a specific revision. Modifies the database structure from where it is, stepwise through revisions, to the specified revision.

Parameters:
  • revision – destination revision
  • show_sql_only – just show the SQL; don’t execute it