32d636cb5e00_display_name_in_groups.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. """display_name_in_groups
  2. Revision ID: 32d636cb5e00
  3. Revises: 43df5e588a87
  4. Create Date: 2016-08-13 02:54:27.199948
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = '32d636cb5e00'
  8. down_revision = '43df5e588a87'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. def upgrade():
  12. ''' Add attributes display name and description in PagureGroup '''
  13. op.add_column(
  14. 'pagure_group',
  15. sa.Column(
  16. 'display_name',
  17. sa.String(255),
  18. nullable=True,
  19. unique=True,
  20. )
  21. )
  22. op.execute('''UPDATE "pagure_group" SET display_name=group_name; ''')
  23. op.alter_column(
  24. 'pagure_group',
  25. column_name='display_name',
  26. nullable=False,
  27. existing_nullable=True
  28. )
  29. op.add_column(
  30. 'pagure_group',
  31. sa.Column(
  32. 'description',
  33. sa.String(255),
  34. nullable=True,
  35. )
  36. )
  37. def downgrade():
  38. ''' Remove attributes display name and description in PagureGroup '''
  39. op.drop_column('pagure_group', 'display_name')
  40. op.drop_column('pagure_group', 'description')