Warning

This document is for an old release of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

galaxy.model.migrations package

class galaxy.model.migrations.DatabaseConfig(url, template, encoding)[source]

Bases: tuple

property url

Alias for field number 0

property template

Alias for field number 1

property encoding

Alias for field number 2

exception galaxy.model.migrations.NoVersionTableError(model: str)[source]

Bases: Exception

__init__(model: str) None[source]
exception galaxy.model.migrations.IncorrectVersionError(model: str, expected_version: int)[source]

Bases: Exception

__init__(model: str, expected_version: int) None[source]
exception galaxy.model.migrations.OutdatedDatabaseError(model: str, db_version: str, code_version: str)[source]

Bases: Exception

__init__(model: str, db_version: str, code_version: str) None[source]
exception galaxy.model.migrations.InvalidModelIdError(model: str)[source]

Bases: Exception

__init__(model: str) None[source]
exception galaxy.model.migrations.RevisionNotFoundError(model: str)[source]

Bases: Exception

__init__(model: str) None[source]
class galaxy.model.migrations.AlembicManager(engine: Engine, config_dict: Optional[dict] = None)[source]

Bases: object

Alembic operations on one database.

static is_at_revision(engine: Engine, revision: Union[str, Iterable[str]]) bool[source]

True if revision is a subset of the set of version heads stored in the database.

__init__(engine: Engine, config_dict: Optional[dict] = None) None[source]
stamp_model_head(model: ModelId) None[source]

Partial proxy to alembic’s stamp command.

stamp_revision(revision: Union[str, Iterable[str]]) None[source]

Partial proxy to alembic’s stamp command.

upgrade(model: ModelId) None[source]

Partial proxy to alembic’s upgrade command.

is_under_version_control(model: ModelId) bool[source]

True if the database version table contains a revision that corresponds to a revision in the script directory that has branch label model.

is_up_to_date(model: ModelId) bool[source]

True if the head revision for model in the script directory is stored in the database.

get_model_db_head(model: ModelId) Optional[str][source]
get_model_script_head(model: ModelId) Optional[str][source]
property db_heads: Iterable
class galaxy.model.migrations.DatabaseStateCache(engine: Engine)[source]

Bases: object

Snapshot of database state.

__init__(engine: Engine) None[source]
property tables: Dict[str, Table]
is_database_empty() bool[source]
contains_only_kombu_tables() bool[source]
has_alembic_version_table() bool[source]
has_sqlalchemymigrate_version_table() bool[source]
is_last_sqlalchemymigrate_version(last_version: int) bool[source]
galaxy.model.migrations.metadata_contains_only_kombu_tables(metadata: MetaData) bool[source]

Return True if metadata contains only kombu-related tables. (ref: https://github.com/galaxyproject/galaxy/issues/13689)

galaxy.model.migrations.verify_databases_via_script(gxy_config: DatabaseConfig, tsi_config: DatabaseConfig, is_auto_migrate: bool = False) None[source]
galaxy.model.migrations.verify_databases(gxy_engine: Engine, gxy_template: Optional[str], gxy_encoding: Optional[str], tsi_engine: Optional[Engine], tsi_template: Optional[str], tsi_encoding: Optional[str], is_auto_migrate: bool) None[source]
class galaxy.model.migrations.DatabaseStateVerifier(engine: Engine, model: ModelId, database_template: Optional[str], database_encoding: Optional[str], is_auto_migrate: bool, is_new_database: Optional[bool] = False)[source]

Bases: object

__init__(engine: Engine, model: ModelId, database_template: Optional[str], database_encoding: Optional[str], is_auto_migrate: bool, is_new_database: Optional[bool] = False) None[source]
property is_auto_migrate: bool
property db_state: DatabaseStateCache
property alembic_manager: AlembicManager
run() None[source]
galaxy.model.migrations.get_last_sqlalchemymigrate_version(model: ModelId) int[source]
galaxy.model.migrations.get_url_string(engine: Engine) str[source]
galaxy.model.migrations.get_alembic_manager(engine: Engine) AlembicManager[source]
galaxy.model.migrations.get_metadata(model: ModelId) MetaData[source]
galaxy.model.migrations.load_metadata(metadata: MetaData, engine: Engine) None[source]
galaxy.model.migrations.listify(data: Union[str, Iterable[str]]) Iterable[str][source]
galaxy.model.migrations.get_gxy_metadata() MetaData[source]
galaxy.model.migrations.get_tsi_metadata() MetaData[source]

Submodules

galaxy.model.migrations.scripts module

exception galaxy.model.migrations.scripts.DatabaseDoesNotExistError(db_url: str)[source]

Bases: Exception

__init__(db_url: str) None[source]
exception galaxy.model.migrations.scripts.DatabaseNotInitializedError(db_url: str)[source]

Bases: Exception

__init__(db_url: str) None[source]
galaxy.model.migrations.scripts.verify_database_is_initialized(db_url: str) None[source]

Intended for use by scripts that run database migrations (manage_db.sh, run_alembic.sh). Those scripts are meant to run on a database that has been initialized with the appropriate metadata (e.g. galaxy or install model).

This function will raise an error if the database does not exist or has not been initialized*.

NOTE: this function cannot determine whether a database has been properly initialized; it can only tell when a database has *not been initialized.

galaxy.model.migrations.scripts.get_configuration(argv: List[str], cwd: str) Tuple[DatabaseConfig, DatabaseConfig, bool][source]

Return a 3-item-tuple with configuration values used for managing databases.

galaxy.model.migrations.scripts.get_configuration_from_file(cwd: str, config_file: Optional[str] = None) Tuple[DatabaseConfig, DatabaseConfig, bool][source]
galaxy.model.migrations.scripts.add_db_urls_to_command_arguments(argv: List[str], gxy_url: str, tsi_url: str) None[source]
galaxy.model.migrations.scripts.invoke_alembic() None[source]

Invoke the Alembic command line runner.

Accept ‘heads’ as the target revision argument to enable upgrading both gxy and tsi in one command. This is consistent with Alembic’s CLI, which allows upgrade heads. However, this would not work for separate gxy and tsi databases: we can’t attach a database url to a revision after Alembic has been invoked with the ‘upgrade’ command and the ‘heads’ argument. So, instead we invoke Alembic for each head.

exception galaxy.model.migrations.scripts.LegacyScriptsException(message: str)[source]

Bases: Exception

__init__(message: str) None[source]
class galaxy.model.migrations.scripts.LegacyManageDb[source]

Bases: object

LEGACY_CONFIG_FILE_ARG_NAMES = ['-c', '--config', '--config-file']
__init__()[source]
get_gxy_version()[source]

Get the head revision for the gxy branch from the Alembic script directory. (previously referred to as “max/repository version”)

get_gxy_db_version(gxy_db_url=None)[source]

Get the head revision for the gxy branch from the galaxy database. If there is no alembic_version table, get the sqlalchemy migrate version. Raise error if that version is not the latest. (previously referred to as “database version”)

run_upgrade(gxy_db_url=None, tsi_db_url=None)[source]

Alembic will upgrade both branches, gxy and tsi, to their head revisions.

rename_config_argument(argv: List[str]) None[source]

Rename the optional config argument: we can’t use ‘-c’ because that option is used by Alembic.

galaxy.model.migrations.scripts.get_alembic_cfg()[source]
galaxy.model.migrations.scripts.get_alembic_manager(engine: Engine) AlembicManager[source]

galaxy.model.migrations.util module

galaxy.model.migrations.util.drop_column(table_name, column_name)[source]
galaxy.model.migrations.util.column_exists(table_name, column_name)[source]