Skip to content

Commit a854720

Browse files
committed
Migration added
1 parent fc8ceac commit a854720

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

ckanext/datapusher_plus/migration/datapusher_plus/versions/03_23d45fa26447_add_job_key.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@
1717

1818

1919
def upgrade():
20-
op.add_column('jobs', sa.Column('job_key', sa.UnicodeText(), nullable=True))
20+
if not _check_column_exists('jobs', 'job_key'):
21+
op.add_column('jobs', sa.Column('job_key', sa.UnicodeText(), nullable=True))
2122

2223

2324
def downgrade():
2425
op.drop_column('jobs', 'job_key')
26+
27+
28+
def _check_column_exists(table_name, column_name):
29+
bind = op.get_bind()
30+
insp = sa.engine.reflection.Inspector.from_engine(bind)
31+
columns = insp.get_columns(table_name)
32+
return column_name in [column["name"] for column in columns]

0 commit comments

Comments
 (0)