Skip to content

Commit

Permalink
Require test db to be empty for creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ulthran committed Nov 21, 2024
1 parent 0a71ab9 commit a5f471a
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions app/metadatalib/src/metadatalib/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ def create_test_db(session: Session = None):
session = imported_session
Base.metadata.create_all(engine)

if "sqlite" not in SQLALCHEMY_DATABASE_URI:
print("Not a SQLite database, skipping test database creation.")
sys.exit(1)

if session.query(Project).count():
session.execute(delete(Project))
session.execute(delete(Submission))
session.execute(delete(Sample))
session.execute(delete(Annotation))
sys.stderr.write(
"Database already contains data, skipping test data creation\n"
)
sys.exit(1)

p1 = Project(
project_id=1,
Expand Down

0 comments on commit a5f471a

Please sign in to comment.