Blame alembic/versions/32d636cb5e00_display_name_in_groups.py

Vivek Anand 6a5115
"""display_name_in_groups
Vivek Anand 6a5115
Vivek Anand 6a5115
Revision ID: 32d636cb5e00
Vivek Anand 6a5115
Revises: 43df5e588a87
Vivek Anand 6a5115
Create Date: 2016-08-13 02:54:27.199948
Vivek Anand 6a5115
Vivek Anand 6a5115
"""
Vivek Anand 6a5115
Vivek Anand 6a5115
# revision identifiers, used by Alembic.
Vivek Anand 6a5115
revision = '32d636cb5e00'
Vivek Anand 6a5115
down_revision = '43df5e588a87'
Vivek Anand 6a5115
Vivek Anand 6a5115
from alembic import op
Vivek Anand 6a5115
import sqlalchemy as sa
Vivek Anand 6a5115
Vivek Anand 6a5115
Vivek Anand 6a5115
def upgrade():
Vivek Anand 6a5115
    ''' Add attributes display name and description in PagureGroup '''
Vivek Anand 6a5115
    op.add_column(
Vivek Anand 6a5115
        'pagure_group',
Vivek Anand 6a5115
        sa.Column(
Vivek Anand 6a5115
            'display_name',
Vivek Anand 6a5115
            sa.String(255),
Vivek Anand 6a5115
            nullable=True,
Vivek Anand 6a5115
            unique=True,
Vivek Anand 6a5115
        )
Vivek Anand 6a5115
    )
Vivek Anand 6a5115
Vivek Anand 6a5115
    op.execute('''UPDATE "pagure_group" SET display_name=group_name; ''')
Vivek Anand 6a5115
Vivek Anand 6a5115
    op.alter_column(
Vivek Anand 6a5115
        'pagure_group',
Vivek Anand 6a5115
        column_name='display_name',
Vivek Anand 6a5115
        nullable=False,
Vivek Anand 6a5115
        existing_nullable=True
Vivek Anand 6a5115
        )
Vivek Anand 6a5115
Vivek Anand 6a5115
    op.add_column(
Vivek Anand 6a5115
        'pagure_group',
Vivek Anand 6a5115
        sa.Column(
Vivek Anand 6a5115
            'description',
Vivek Anand 6a5115
            sa.String(255),
Vivek Anand 6a5115
            nullable=True,
Vivek Anand 6a5115
        )
Vivek Anand 6a5115
    )
Vivek Anand 6a5115
Vivek Anand 6a5115
Vivek Anand 6a5115
def downgrade():
Vivek Anand 6a5115
    ''' Remove attributes display name and description in PagureGroup '''
Vivek Anand 6a5115
Vivek Anand 6a5115
    op.drop_column('pagure_group', 'display_name')
Vivek Anand 6a5115
    op.drop_column('pagure_group', 'description')
Vivek Anand 6a5115