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
- class galaxy.model.migrations.AlembicManager(engine: Engine, config_dict: Optional[dict] = None)[source]¶
Bases:
BaseAlembicManager
- is_up_to_date(model: ModelId) bool [source]¶
True if the head revision for model in the script directory is stored in the database.
- 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 db_state: DatabaseStateCache¶
- property alembic_manager: AlembicManager¶
- galaxy.model.migrations.get_alembic_manager(engine: Engine) AlembicManager [source]¶
Submodules¶
galaxy.model.migrations.scripts module¶
- 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.
- class galaxy.model.migrations.scripts.LegacyManageDb[source]¶
Bases:
object
- LEGACY_CONFIG_FILE_ARG_NAMES = ['-c', '--config', '--config-file']¶
- 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”)
- galaxy.model.migrations.scripts.get_alembic_manager(engine: Engine) AlembicManager [source]¶
galaxy.model.migrations.util module¶
- class galaxy.model.migrations.util.DDLOperation[source]¶
Bases:
ABC
Base class for all DDL operations.
- class galaxy.model.migrations.util.DDLAlterOperation(table_name: str)[source]¶
Bases:
DDLOperation
Base class for DDL operations that implement special handling of ALTER statements. Ref: - https://alembic.sqlalchemy.org/en/latest/ops.html#alembic.operations.Operations.batch_alter_table - https://alembic.sqlalchemy.org/en/latest/batch.html
- class galaxy.model.migrations.util.CreateTable(table_name: str, *columns: SchemaItem)[source]¶
Bases:
DDLOperation
Wraps alembic’s create_table directive.
- class galaxy.model.migrations.util.DropTable(table_name: str)[source]¶
Bases:
DDLOperation
Wraps alembic’s drop_table directive.
- class galaxy.model.migrations.util.CreateIndex(index_name: str, table_name: str, columns: Sequence, **kw: Any)[source]¶
Bases:
DDLOperation
Wraps alembic’s create_index directive.
- class galaxy.model.migrations.util.DropIndex(index_name: str, table_name: str)[source]¶
Bases:
DDLOperation
Wraps alembic’s drop_index directive.
- class galaxy.model.migrations.util.AddColumn(table_name: str, column: Column)[source]¶
Bases:
DDLOperation
Wraps alembic’s add_column directive.
- class galaxy.model.migrations.util.DropColumn(table_name: str, column_name: str)[source]¶
Bases:
DDLAlterOperation
Wraps alembic’s drop_column directive.
- class galaxy.model.migrations.util.AlterColumn(table_name: str, column_name: str, **kw: Any)[source]¶
Bases:
DDLAlterOperation
Wraps alembic’s alter_column directive.
- class galaxy.model.migrations.util.CreateForeignKey(foreign_key_name: str, table_name: str, referent_table: str, local_cols: List[str], remote_cols: List[str], **kw: Any)[source]¶
Bases:
DDLAlterOperation
Wraps alembic’s create_foreign_key directive.
- class galaxy.model.migrations.util.CreateUniqueConstraint(constraint_name: str, table_name: str, columns: List[str])[source]¶
Bases:
DDLAlterOperation
Wraps alembic’s create_unique_constraint directive.
- class galaxy.model.migrations.util.DropConstraint(constraint_name: str, table_name: str)[source]¶
Bases:
DDLAlterOperation
Wraps alembic’s drop_constraint directive.
- galaxy.model.migrations.util.create_table(table_name: str, *columns: SchemaItem) Optional[Table] [source]¶
- galaxy.model.migrations.util.create_foreign_key(foreign_key_name: str, table_name: str, referent_table: str, local_cols: List[str], remote_cols: List[str], **kw: Any) None [source]¶
- galaxy.model.migrations.util.create_unique_constraint(constraint_name: str, table_name: str, columns: List[str]) None [source]¶
- galaxy.model.migrations.util.table_exists(table_name: str, default: bool) bool [source]¶
Check if table exists. If running in offline mode, return default.
- galaxy.model.migrations.util.column_exists(table_name: str, column_name: str, default: bool) bool [source]¶
Check if column exists. If running in offline mode, return default.
- galaxy.model.migrations.util.index_exists(index_name: str, table_name: str, default: bool) bool [source]¶
Check if index exists. If running in offline mode, return default.
- galaxy.model.migrations.util.foreign_key_exists(constraint_name: str, table_name: str, default: bool) bool [source]¶
Check if unique constraint exists. If running in offline mode, return default.
- galaxy.model.migrations.util.unique_constraint_exists(constraint_name: str, table_name: str, default: bool) bool [source]¶
Check if unique constraint exists. If running in offline mode, return default.
- galaxy.model.migrations.util.legacy_alter_table()[source]¶
Wrapper required for add/drop column statements. Prevents error when column belongs to a table referenced in a view. Relevant to sqlite only. Ref: https://github.com/sqlalchemy/alembic/issues/1207 Ref: https://sqlite.org/pragma.html#pragma_legacy_alter_table
- galaxy.model.migrations.util.transaction()[source]¶
Wraps multiple statements in upgrade/downgrade revision script functions in a database transaction, ensuring transactional control.
Used for SQLite only. Although SQLite supports transactional DDL, pysqlite does not. Ref: https://bugs.python.org/issue10740