Commit 5b721faa authored by Daniele Venzano's avatar Daniele Venzano

Drop the schema before creating new tables to account for versions mismatches during testing

parent fb345e6d
......@@ -15,9 +15,15 @@
"""Create the DB tables needed by Zoe. This script is used in the CI pipeline to prevent race conditions with zoe-api automatically creating the tables while zoe-master is starting at the same time."""
import time
import zoe_lib.config as config
import zoe_api.db_init
print("Warning, this script will delete the database tables for the deployment '{}' before creating new ones".format(config.get_conf().deployment_name))
print("Sleeping 5 seconds before continuing, hit CTRL-C to stop and think.")
......@@ -108,7 +108,7 @@ def create_tables(cur):
def init():
def init(force=False):
"""DB init entrypoint."""
dsn = 'dbname=' + get_conf().dbname + \
' user=' + get_conf().dbuser + \
......@@ -121,6 +121,11 @@ def init():
cur.execute('SET search_path TO {},public'.format(get_conf().deployment_name))
if force:
cur.execute("DELETE FROM public.versions WHERE deployment = %s", (get_conf().deployment_name,))
cur.execute('DROP SCHEMA {} CASCADE'.format(get_conf().deployment_name))
if not check_schema_version(cur, get_conf().deployment_name):
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment