Warning

This document is for an in-development version 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.

Source code for galaxy.model.migrate.versions.0143_add_cloudauthz_tables

"""
Migration script to add a new tables for CloudAuthz (tokens required to access cloud-based resources).
"""

import logging

from sqlalchemy import Column, DateTime, ForeignKey, Integer, MetaData, String, Table, TEXT

from galaxy.model.custom_types import JSONType

log = logging.getLogger(__name__)
metadata = MetaData()

cloudauthz = Table(
    "cloudauthz", metadata,
    Column('id', Integer, primary_key=True),
    Column("user_id", Integer, ForeignKey("galaxy_user.id"), index=True),
    Column('provider', String(255)),
    Column('config', JSONType),
    Column('authn_id', Integer, ForeignKey("oidc_user_authnz_tokens.id"), index=True),
    Column('tokens', JSONType),
    Column('last_update', DateTime),
    Column('last_activity', DateTime),
    Column('description', TEXT))


[docs]def upgrade(migrate_engine): print(__doc__) metadata.bind = migrate_engine metadata.reflect() try: cloudauthz.create() except Exception: log.exception("Failed to create cloudauthz table")
[docs]def downgrade(migrate_engine): metadata.bind = migrate_engine metadata.reflect() try: cloudauthz.drop() except Exception: log.exception("Failed to drop cloudauthz table")