From 38f6deade84dba648a29e8c1aba9fb2363239963 Mon Sep 17 00:00:00 2001 From: Christian Krakau-Louis Date: Tue, 15 Apr 2025 17:52:08 +0200 Subject: [PATCH] fix: Correct order of database initialization steps in init_db function --- app/db_init.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/db_init.py b/app/db_init.py index 64c176a..b42927f 100644 --- a/app/db_init.py +++ b/app/db_init.py @@ -28,9 +28,11 @@ def table_has_column(engine, table_name, column_name): def init_db(): """Initialize the database, applying migrations and seeding data.""" - # First, run any needed migrations + # First, create all tables if they don't exist + from .models import Base + Base.metadata.create_all(bind=engine) + # Then, run any needed migrations run_migrations(engine) - # Then proceed with seeding if needed seed_db()