ba538b2648b7_create_hook_mirror_table.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. """create hook_mirror table
  2. Revision ID: ba538b2648b7
  3. Revises: 19b67f4b9fe4
  4. Create Date: 2018-09-27 12:47:21.975843
  5. """
  6. # revision identifiers, used by Alembic.
  7. revision = 'ba538b2648b7'
  8. down_revision = '19b67f4b9fe4'
  9. from alembic import op
  10. import sqlalchemy as sa
  11. def upgrade():
  12. """ Create the hook_mirror to store the tags of pull-requests.
  13. """
  14. op.create_table(
  15. 'hook_mirror',
  16. sa.Column(
  17. 'id',
  18. sa.Integer,
  19. primary_key=True),
  20. sa.Column(
  21. 'project_id',
  22. sa.Integer,
  23. sa.ForeignKey(
  24. 'projects.id', onupdate='CASCADE', ondelete='CASCADE'
  25. ),
  26. nullable=False,
  27. primary_key=True
  28. ),
  29. sa.Column(
  30. 'active',
  31. sa.Boolean,
  32. nullable=False,
  33. default=False
  34. ),
  35. sa.Column(
  36. 'public_key',
  37. sa.Text,
  38. nullable=True
  39. ),
  40. sa.Column(
  41. 'target',
  42. sa.Text,
  43. nullable=True
  44. ),
  45. sa.Column(
  46. 'last_log',
  47. sa.Text,
  48. nullable=True
  49. )
  50. )
  51. def downgrade():
  52. """ Delete the hook_mirror table. """
  53. op.drop_table('hook_mirror')