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.0024_page_slug_unique_constraint

"""
Remove unique constraint from page slugs to allow creating a page with
the same slug as a deleted page.
"""
from __future__ import print_function

import logging

from sqlalchemy import (
    MetaData,
    Table
)

from galaxy.model.migrate.versions.util import (
    add_index,
    drop_index
)

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


[docs]def upgrade(migrate_engine): print(__doc__) metadata.bind = migrate_engine metadata.reflect() Page_table = Table("page", metadata, autoload=True) try: # Sqlite doesn't support .alter, so we need to drop an recreate drop_index("ix_page_slug", Page_table, 'slug') add_index("ix_page_slug", Page_table, 'slug', unique=False) except Exception: # Mysql doesn't have a named index, but alter should work Page_table.c.slug.alter(unique=False)
[docs]def downgrade(migrate_engine): pass