Skip to content

Commit

Permalink
only call create_all if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii committed Dec 5, 2024
1 parent 79d3d34 commit a90a189
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions prediction_market_agent_tooling/tools/db/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ def create_tables(
tables_to_create = None

# Create tables in the database
with self.get_connection() as connection:
SQLModel.metadata.create_all(connection, tables=tables_to_create)
connection.commit()
if tables_to_create is None or len(tables_to_create) > 0:
with self.get_connection() as connection:
SQLModel.metadata.create_all(connection, tables=tables_to_create)
connection.commit()

# Update cache to mark tables as initialized
if tables_to_create:
Expand Down

0 comments on commit a90a189

Please sign in to comment.