2e9819ca5b28_add_tenant_id_in_api_token.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. """add_tenant_id_in_api_token
  2. Revision ID: 2e9819ca5b28
  3. Revises: 6e2cfb077b04
  4. Create Date: 2023-09-22 15:41:01.243183
  5. """
  6. import sqlalchemy as sa
  7. from alembic import op
  8. from sqlalchemy.dialects import postgresql
  9. # revision identifiers, used by Alembic.
  10. revision = '2e9819ca5b28'
  11. down_revision = 'ab23c11305d4'
  12. branch_labels = None
  13. depends_on = None
  14. def upgrade():
  15. # ### commands auto generated by Alembic - please adjust! ###
  16. with op.batch_alter_table('api_tokens', schema=None) as batch_op:
  17. batch_op.add_column(sa.Column('tenant_id', postgresql.UUID(), nullable=True))
  18. batch_op.create_index('api_token_tenant_idx', ['tenant_id', 'type'], unique=False)
  19. batch_op.drop_column('dataset_id')
  20. # ### end Alembic commands ###
  21. def downgrade():
  22. # ### commands auto generated by Alembic - please adjust! ###
  23. with op.batch_alter_table('api_tokens', schema=None) as batch_op:
  24. batch_op.add_column(sa.Column('dataset_id', postgresql.UUID(), autoincrement=False, nullable=True))
  25. batch_op.drop_index('api_token_tenant_idx')
  26. batch_op.drop_column('tenant_id')
  27. # ### end Alembic commands ###