Skip to content

Commit

Permalink
Use a local fn
Browse files Browse the repository at this point in the history
  • Loading branch information
piazzatron committed May 13, 2022
1 parent b81e2aa commit 4c36525
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 2 additions & 8 deletions discovery-provider/alembic/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import os
import re

from alembic import context, op
from alembic import context
from alembic.ddl.base import AddColumn, DropColumn, visit_add_column, visit_drop_column
from sqlalchemy import engine_from_config, pool, inspect
from sqlalchemy import engine_from_config, pool
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.schema import CreateIndex, CreateTable, DropIndex, DropTable

Expand Down Expand Up @@ -114,12 +114,6 @@ def _add_if_exists(element, compiler, **kw):
)


def column_exists(table_name, column_name):
bind = op.get_context().bind
insp = inspect(bind)
columns = insp.get_columns(table_name)
return any(c["name"] == column_name for c in columns)

if context.is_offline_mode():
run_migrations_offline()
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
Create Date: 2022-05-09 22:03:16.838837
"""
import sqlalchemy as sa
import sqlalchemy as sa, inspect
from alembic import op
from alembic.env import column_exists

# revision identifiers, used by Alembic.
revision = "0d2067242dd5"
down_revision = "35198266d709"
branch_labels = None
depends_on = None

def column_exists(table_name, column_name):
bind = op.get_context().bind
insp = inspect(bind)
columns = insp.get_columns(table_name)
return any(c["name"] == column_name for c in columns)

def upgrade():
# Handle lack of idempotency for this migration
Expand Down

0 comments on commit 4c36525

Please sign in to comment.