From cbced47e99a2a005b9bad055636d920fb69102d7 Mon Sep 17 00:00:00 2001 From: Per-Arne Date: Thu, 23 Apr 2020 10:49:45 +0200 Subject: [PATCH] * Fixed migrations --- .../migrations/versions/001_add_dns_column.py | 9 +++++--- .../versions/002_remove_server_shared_key.py | 21 ++++++++++++------- .../versions/003_create_client_shared_key.py | 10 +++++---- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/wg_dashboard_backend/migrations/versions/001_add_dns_column.py b/wg_dashboard_backend/migrations/versions/001_add_dns_column.py index bc7036a..bcaed54 100644 --- a/wg_dashboard_backend/migrations/versions/001_add_dns_column.py +++ b/wg_dashboard_backend/migrations/versions/001_add_dns_column.py @@ -12,6 +12,9 @@ def upgrade(migrate_engine): def downgrade(migrate_engine): - meta = MetaData(bind=migrate_engine) - dns = Table('peer', meta, autoload=True) - dns.c.email.drop() + try: + meta = MetaData(bind=migrate_engine) + dns = Table('peer', meta, autoload=True) + dns.c.email.drop() + except: + pass diff --git a/wg_dashboard_backend/migrations/versions/002_remove_server_shared_key.py b/wg_dashboard_backend/migrations/versions/002_remove_server_shared_key.py index c6215a3..7b71c47 100644 --- a/wg_dashboard_backend/migrations/versions/002_remove_server_shared_key.py +++ b/wg_dashboard_backend/migrations/versions/002_remove_server_shared_key.py @@ -3,14 +3,19 @@ from migrate import * def upgrade(migrate_engine): - meta = MetaData(bind=migrate_engine) - server = Table('server', meta, autoload=True) - server.c.shared_key.drop() + try: + meta = MetaData(bind=migrate_engine) + server = Table('server', meta, autoload=True) + server.c.shared_key.drop() + except: + pass def downgrade(migrate_engine): - meta = MetaData(bind=migrate_engine) - account = Table('server', meta, autoload=True) - shared_key = Column('shared_key', Text) - shared_key.create(account) - + try: + meta = MetaData(bind=migrate_engine) + account = Table('server', meta, autoload=True) + shared_key = Column('shared_key', Text) + shared_key.create(account) + except: + pass diff --git a/wg_dashboard_backend/migrations/versions/003_create_client_shared_key.py b/wg_dashboard_backend/migrations/versions/003_create_client_shared_key.py index 12ad910..ead92e2 100644 --- a/wg_dashboard_backend/migrations/versions/003_create_client_shared_key.py +++ b/wg_dashboard_backend/migrations/versions/003_create_client_shared_key.py @@ -13,7 +13,9 @@ def upgrade(migrate_engine): def downgrade(migrate_engine): - meta = MetaData(bind=migrate_engine) - dns = Table('peer', meta, autoload=True) - dns.c.shared_key.drop() - + try: + meta = MetaData(bind=migrate_engine) + dns = Table('peer', meta, autoload=True) + dns.c.shared_key.drop() + except: + pass