Skip to content

Commit

Permalink
filter for error message on duplicate column
Browse files Browse the repository at this point in the history
Creating/upgrading the database will not diplay the error of a duplicate column.

Closes #261
  • Loading branch information
cornelinux committed Nov 13, 2015
1 parent 164363d commit 327e0a0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
11 changes: 11 additions & 0 deletions migrations/versions/20969b4cbf06_.py
Expand Up @@ -12,13 +12,19 @@

from alembic import op
import sqlalchemy as sa
from sqlalchemy.exc import OperationalError


def upgrade():
try:
op.add_column('token', sa.Column('revoked', sa.Boolean(),
nullable=False,
default=False))
except OperationalError as exx:
if exx.orig.message.startswith("duplicate column name"):
print("Good. Column revoked already exists.")
else:
print(exx)
except Exception as exx:
print ("Could not add column 'revoked' to table 'token'")
print (exx)
Expand All @@ -27,6 +33,11 @@ def upgrade():
op.add_column('token', sa.Column('locked', sa.Boolean(),
nullable=False,
default=False))
except OperationalError as exx:
if exx.orig.message.startswith("duplicate column name"):
print("Good. Column locked already exists.")
else:
print(exx)
except Exception as exx:
print ("Could not add column 'locked' to table 'token'")
print (exx)
Expand Down
6 changes: 6 additions & 0 deletions migrations/versions/2181294eed0b_.py
Expand Up @@ -12,11 +12,17 @@

from alembic import op
import sqlalchemy as sa
from sqlalchemy.exc import OperationalError


def upgrade():
try:
op.add_column('policy', sa.Column('condition', sa.Integer(), nullable=False))
except OperationalError as exx:
if exx.orig.message.startswith("duplicate column name"):
print("Good. Column condition already exists.")
else:
print(exx)
except Exception as exx:
print ("Could not add column 'condition' to table 'policy'")
print (exx)
Expand Down
6 changes: 6 additions & 0 deletions migrations/versions/2551ee982544_.py
Expand Up @@ -12,11 +12,17 @@

from alembic import op
import sqlalchemy as sa
from sqlalchemy.exc import OperationalError


def upgrade():
try:
op.add_column('tokeninfo', sa.Column('Type', sa.Unicode(length=100), nullable=True))
except OperationalError as exx:
if exx.orig.message.startswith("duplicate column name"):
print("Good. Column tokeninfo already exists.")
else:
print(exx)
except Exception as exx:
print("Could not add the column 'Type' to table tokeninfo")
print (exx)
Expand Down
6 changes: 6 additions & 0 deletions migrations/versions/4d9178fa8336_.py
Expand Up @@ -12,13 +12,19 @@

from alembic import op
import sqlalchemy as sa
from sqlalchemy.exc import OperationalError


def upgrade():
try:
op.add_column('policy', sa.Column('adminrealm',
sa.Unicode(length=256),
nullable=True))
except OperationalError as exx:
if exx.orig.message.startswith("duplicate column name"):
print("Good. Column adminrealm already exists.")
else:
print(exx)
except Exception as exx:
print("Could not add the column 'adminrealm' to table policy")
print(exx)
Expand Down
6 changes: 6 additions & 0 deletions migrations/versions/e5cbeb7c177_.py
Expand Up @@ -12,12 +12,18 @@

from alembic import op
import sqlalchemy as sa
from sqlalchemy.exc import OperationalError


def upgrade():
try:
op.add_column('resolverrealm', sa.Column('priority', sa.Integer(),
nullable=True))
except OperationalError as exx:
if exx.orig.message.startswith("duplicate column name"):
print("Good. Column priority already exists.")
else:
print(exx)
except Exception as exx:
print ("Could not add column 'priority' to table 'resolverrealm'")
print (exx)
Expand Down

0 comments on commit 327e0a0

Please sign in to comment.