968fff4c0ab9_add_api_based_extension.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """add_api_based_extension
  2. Revision ID: 968fff4c0ab9
  3. Revises: b3a09c049e8e
  4. Create Date: 2023-10-27 13:05:58.901858
  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 = '968fff4c0ab9'
  11. down_revision = 'b3a09c049e8e'
  12. branch_labels = None
  13. depends_on = None
  14. def upgrade():
  15. # ### commands auto generated by Alembic - please adjust! ###
  16. op.create_table('api_based_extensions',
  17. sa.Column('id', postgresql.UUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False),
  18. sa.Column('tenant_id', postgresql.UUID(), nullable=False),
  19. sa.Column('name', sa.String(length=255), nullable=False),
  20. sa.Column('api_endpoint', sa.String(length=255), nullable=False),
  21. sa.Column('api_key', sa.Text(), nullable=False),
  22. sa.Column('created_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP(0)'), nullable=False),
  23. sa.PrimaryKeyConstraint('id', name='api_based_extension_pkey')
  24. )
  25. with op.batch_alter_table('api_based_extensions', schema=None) as batch_op:
  26. batch_op.create_index('api_based_extension_tenant_idx', ['tenant_id'], unique=False)
  27. # ### end Alembic commands ###
  28. def downgrade():
  29. # ### commands auto generated by Alembic - please adjust! ###
  30. with op.batch_alter_table('api_based_extensions', schema=None) as batch_op:
  31. batch_op.drop_index('api_based_extension_tenant_idx')
  32. op.drop_table('api_based_extensions')
  33. # ### end Alembic commands ###