Açıklama Yok

f727badcc4e1_add_alert_in_comments.py 905B

123456789101112131415161718192021222324252627282930313233343536
  1. """Add alert in comments
  2. Revision ID: f727badcc4e1
  3. Revises: 50f28953a485
  4. Create Date: 2023-04-12 09:28:58.993723
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. from app.alembic.alembic_utils import _table_has_column
  9. # revision identifiers, used by Alembic.
  10. revision = 'f727badcc4e1'
  11. down_revision = '50f28953a485'
  12. branch_labels = None
  13. depends_on = None
  14. def upgrade():
  15. if not _table_has_column("comments", "comment_alert_id"):
  16. op.add_column('comments',
  17. sa.Column('comment_alert_id',
  18. sa.BigInteger(), nullable=True)
  19. )
  20. op.create_foreign_key(None,
  21. 'comments', 'alerts',
  22. ['comment_alert_id'], ['alert_id'])
  23. def downgrade():
  24. op.drop_constraint(None, 'comments', type_='foreignkey')
  25. op.drop_column('comments', 'comment_alert_id')
  26. pass