diff --git a/app/seeders/database_seeder.py b/app/seeders/database_seeder.py index db66f9d..c48f0b4 100644 --- a/app/seeders/database_seeder.py +++ b/app/seeders/database_seeder.py @@ -9,19 +9,23 @@ from app.seeders.user_seeder import seed_users def seed_all(db: Session, count: int = 5): - business_types = seed_business_types(db, count) - plans = seed_plans(db, count) + try: + business_types = seed_business_types(db, count) + plans = seed_plans(db, count) - bt_ids = [bt.id for bt in business_types] - tenants = seed_tenants(db, count, business_type_ids=bt_ids) + bt_ids = [bt.id for bt in business_types] + tenants = seed_tenants(db, count, business_type_ids=bt_ids) - plan_ids = [p.id for p in plans] - tenant_ids = [t.id for t in tenants] - seed_subscriptions(db, count, tenant_ids=tenant_ids, plan_ids=plan_ids) + plan_ids = [p.id for p in plans] + tenant_ids = [t.id for t in tenants] + seed_subscriptions(db, count, tenant_ids=tenant_ids, plan_ids=plan_ids) - users = seed_users(db, count) + users = seed_users(db, count) - db.commit() + db.commit() + except: + db.rollback() + raise return { "business_types": len(business_types),