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.

Source code for tool_shed.webapp.model.migrate.versions.0025_session_timeout

"""
Migration script to add session update time (used for timeouts)
"""

import datetime
import logging

from sqlalchemy import Column, DateTime, MetaData, Table

now = datetime.datetime.utcnow
log = logging.getLogger(__name__)
metadata = MetaData()


[docs]def upgrade(migrate_engine): metadata.bind = migrate_engine print(__doc__) metadata.reflect() lastaction_column = Column("last_action", DateTime) __add_column(lastaction_column, "galaxy_session", metadata)
[docs]def downgrade(migrate_engine): metadata.bind = migrate_engine metadata.reflect() __drop_column("last_action", "galaxy_session", metadata)
def __add_column(column, table_name, metadata, **kwds): try: table = Table(table_name, metadata, autoload=True) column.create(table, **kwds) except Exception: log.exception("Adding column %s failed.", column) def __drop_column(column_name, table_name, metadata): try: table = Table(table_name, metadata, autoload=True) getattr(table.c, column_name).drop() except Exception: log.exception("Dropping column %s failed.", column_name)