31 lines
792 B
Python
31 lines
792 B
Python
"""add connection_token column
|
|
|
|
Revision ID: add_connection_token
|
|
Revises: fix_updated_at_trigger
|
|
Create Date: 2024-03-19 13:00:00.000000
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy import inspect
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'add_connection_token'
|
|
down_revision = 'fix_updated_at_trigger'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Get the inspector
|
|
inspector = inspect(op.get_bind())
|
|
|
|
# Check if the column exists
|
|
columns = [col['name'] for col in inspector.get_columns('instances')]
|
|
if 'connection_token' not in columns:
|
|
op.add_column('instances', sa.Column('connection_token', sa.String(64), nullable=True, unique=True))
|
|
|
|
|
|
def downgrade():
|
|
op.drop_column('instances', 'connection_token') |