Нет описания

2df770a4989c_add_objects_attributes.py 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """Add objects attributes
  2. Revision ID: 2df770a4989c
  3. Revises: 10a7616f3cc7
  4. Create Date: 2022-02-11 20:13:14.365469
  5. """
  6. import sqlalchemy as sa
  7. from alembic import op
  8. from app.alembic.alembic_utils import _table_has_column
  9. # revision identifiers, used by Alembic.
  10. revision = '2df770a4989c'
  11. down_revision = '10a7616f3cc7'
  12. branch_labels = None
  13. depends_on = None
  14. def upgrade():
  15. tables = ['ioc', 'case_assets', 'case_received_file', 'case_tasks', 'notes', 'cases_events', 'cases', 'client']
  16. for table in tables:
  17. if not _table_has_column(table, 'custom_attributes'):
  18. op.add_column(table,
  19. sa.Column('custom_attributes', sa.JSON)
  20. )
  21. t_ua = sa.Table(
  22. table,
  23. sa.MetaData(),
  24. sa.Column('custom_attributes', sa.JSON)
  25. )
  26. conn = op.get_bind()
  27. conn.execute(t_ua.update().values(
  28. custom_attributes={}
  29. ))
  30. pass
  31. def downgrade():
  32. pass