1
0

257a7ce22682_add_the_remote_git_entry.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """Add the remote_git entry
  2. Revision ID: 257a7ce22682
  3. Revises: 36116bb7a69b
  4. Create Date: 2015-07-21 14:26:23.989220
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = '257a7ce22682'
  8. down_revision = '36116bb7a69b'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. def upgrade():
  12. ''' Add the column remote_git to the table pull_requests and make the
  13. project_id_from field nullable.
  14. '''
  15. op.add_column(
  16. 'pull_requests',
  17. sa.Column('remote_git', sa.Text, nullable=True)
  18. )
  19. op.alter_column(
  20. 'pull_requests',
  21. column_name='project_id_from',
  22. nullable=True,
  23. existing_nullable=False)
  24. op.create_check_constraint(
  25. "ck_lcl_or_remo_pr",
  26. "pull_requests",
  27. 'NOT(project_id_from IS NULL AND remote_git IS NULL)'
  28. )
  29. def downgrade():
  30. ''' Remove the column remote_git from the table pull_requests and make
  31. the project_id_from field not nullable.
  32. '''
  33. op.drop_column('pull_requests', 'remote_git')
  34. op.alter_column(
  35. 'pull_requests',
  36. column_name='project_id_from',
  37. nullable=False,
  38. existing_nullable=True)