diff --git a/run_migrations.py b/run_migrations.py index 2af6374..8e79a9e 100644 --- a/run_migrations.py +++ b/run_migrations.py @@ -54,8 +54,11 @@ def get_conn(): def ensure_tracking_table(conn): - """Create schema_migrations tracking table if it doesn't exist.""" + """Create schema and schema_migrations tracking table if they don't exist.""" with conn.cursor() as cur: + # Schema may not exist yet on a fresh DB (migration 02 creates it, + # but we need it before we can create the tracking table). + cur.execute("CREATE SCHEMA IF NOT EXISTS tracksolid") cur.execute(""" CREATE TABLE IF NOT EXISTS tracksolid.schema_migrations ( filename TEXT PRIMARY KEY,