Skip to content

Commit

Permalink
Moved seed_db from seed.py to models
Browse files Browse the repository at this point in the history
  • Loading branch information
neilshaabi committed Apr 30, 2024
1 parent 2e9ff11 commit 36c31b5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 38 deletions.
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def inject_globals():
}

with app.app_context():
from app.seed import seed_db
from app.models import seed_db

# Reset database
if app.config["RESET_DB"]:
Expand Down
21 changes: 21 additions & 0 deletions app/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,24 @@ def seed(cls, db: SQLAlchemy, fake: Optional[Faker] = None) -> None:
from .therapy_exercise import TherapyExercise
from .title import Title
from .user import User


# Seed required models in order
def seed_db(db: SQLAlchemy, use_fake_data: bool) -> None:
Title.seed(db)
Language.seed(db)
Issue.seed(db)
Intervention.seed(db)

if use_fake_data:
fake = Faker()
User.seed(db, fake)
Therapist.seed(db, fake)
Client.seed(db, fake)
Conversation.seed(db)
Message.seed(db, fake)
AppointmentType.seed(db, fake)
Appointment.seed(db, fake)
AppointmentNotes.seed(db, fake)
TherapyExercise.seed(db, fake)
return
37 changes: 0 additions & 37 deletions app/seed.py

This file was deleted.

0 comments on commit 36c31b5

Please sign in to comment.