012799339d34_update_log.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. """update_log
  2. Revision ID: 012799339d34
  3. Revises: 948ce5107c93
  4. Create Date: 2019-09-08 14:21:58.698377
  5. """
  6. from alembic import op
  7. import sqlalchemy as sa
  8. # revision identifiers, used by Alembic.
  9. revision = '012799339d34'
  10. down_revision = '948ce5107c93'
  11. branch_labels = None
  12. depends_on = None
  13. def upgrade():
  14. op.add_column('log', sa.Column('request_type', sa.String(), nullable=True))
  15. op.add_column('log', sa.Column('request_url', sa.String(), nullable=True))
  16. op.drop_constraint('fk_log_request_id_request', 'log', type_='foreignkey')
  17. op.drop_column('log', 'request_id')
  18. op.drop_table('request')
  19. def downgrade():
  20. op.drop_column('log', 'request_url')
  21. op.drop_column('log', 'request_type')
  22. op.create_table('request',
  23. sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
  24. sa.Column('name', sa.VARCHAR(), autoincrement=False, nullable=True),
  25. sa.PrimaryKeyConstraint('id', name='pk_request')
  26. )
  27. op.add_column('log', sa.Column('request_id', sa.INTEGER(), autoincrement=False, nullable=True))
  28. op.create_foreign_key('fk_log_request_id_request', 'log', 'request', ['request_id'], ['id'])