1cd0a853c697_add_closed_at_field_in_pr.py 772 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. """Add closed_at field in PR
  2. Revision ID: 1cd0a853c697
  3. Revises: 6190226bed0
  4. Create Date: 2015-10-02 09:32:15.370676
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = '1cd0a853c697'
  8. down_revision = '6190226bed0'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. def upgrade():
  12. ''' Add the column closed_at to the table pull_requests.
  13. '''
  14. op.add_column(
  15. 'pull_requests',
  16. sa.Column(
  17. 'closed_at',
  18. sa.DateTime,
  19. nullable=True,
  20. )
  21. )
  22. op.execute('''UPDATE "pull_requests" SET closed_at=date_created '''
  23. '''WHERE STATUS != 'Open';''')
  24. def downgrade():
  25. ''' Remove the column closed_at from the table pull_requests.
  26. '''
  27. op.drop_column('pull_requests', 'closed_at')