1
0

2b626a16542e_commit_flag.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. """commit flag
  2. Revision ID: 2b626a16542e
  3. Revises: 2fb229dac744
  4. Create Date: 2017-11-15 10:06:55.088665
  5. """
  6. import datetime
  7. from alembic import op
  8. import sqlalchemy as sa
  9. # revision identifiers, used by Alembic.
  10. revision = '2b626a16542e'
  11. down_revision = '2fb229dac744'
  12. def upgrade():
  13. ''' Create the commit_flags table. '''
  14. op.create_table(
  15. 'commit_flags',
  16. sa.Column('id', sa.Integer, primary_key=True),
  17. sa.Column('uid', sa.String(32), unique=True, nullable=False),
  18. sa.Column('commit_hash', sa.String(40), index=True, nullable=False),
  19. sa.Column(
  20. 'token_id', sa.String(64),
  21. sa.ForeignKey('tokens.id'), nullable=False),
  22. sa.Column(
  23. 'project_id',
  24. sa.Integer,
  25. sa.ForeignKey(
  26. 'projects.id', onupdate='CASCADE', ondelete='CASCADE',
  27. ),
  28. nullable=False, index=True),
  29. sa.Column(
  30. 'user_id', sa.Integer,
  31. sa.ForeignKey('users.id', onupdate='CASCADE'),
  32. nullable=False, index=True),
  33. sa.Column('status', sa.String(32), nullable=False),
  34. sa.Column('username', sa.Text(), nullable=False),
  35. sa.Column('percent', sa.Integer(), nullable=True),
  36. sa.Column('comment', sa.Text(), nullable=False),
  37. sa.Column('url', sa.Text(), nullable=False),
  38. sa.Column(
  39. 'date_created', sa.DateTime, nullable=False,
  40. default=datetime.datetime.utcnow),
  41. )
  42. op.create_unique_constraint(
  43. "commit_flags_uid_commit_hash_key",
  44. 'commit_flags',
  45. ["uid", "commit_hash"]
  46. )
  47. def downgrade():
  48. ''' Drop the commit_flags table. '''
  49. op.drop_table('commit_flags')