fix(seed): use SQLAlchemy .is_not(None) instead of Python 'is not None' in queries
The reset_all_data() function used `ContentPage.store_id is not None` which is a Python identity check (always True), causing it to delete ALL content pages including platform defaults. Same bug in print_summary() caused the count to always show 0 platform pages. Fixed both to use proper SQLAlchemy .is_(None) / .is_not(None) syntax. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -707,7 +707,7 @@ def reset_all_data(db: Session):
|
||||
for table in tables_to_clear:
|
||||
if table == ContentPage:
|
||||
# Only delete store content pages, keep platform defaults
|
||||
db.execute(delete(ContentPage).where(ContentPage.store_id is not None))
|
||||
db.execute(delete(ContentPage).where(ContentPage.store_id.is_not(None)))
|
||||
else:
|
||||
db.execute(delete(table))
|
||||
|
||||
@@ -1416,8 +1416,8 @@ def print_summary(db: Session):
|
||||
team_member_count = db.query(StoreUser).count()
|
||||
customer_count = db.query(Customer).count()
|
||||
product_count = db.query(Product).count()
|
||||
platform_pages = db.query(ContentPage).filter(ContentPage.store_id is None).count()
|
||||
store_pages = db.query(ContentPage).filter(ContentPage.store_id is not None).count()
|
||||
platform_pages = db.query(ContentPage).filter(ContentPage.store_id.is_(None)).count()
|
||||
store_pages = db.query(ContentPage).filter(ContentPage.store_id.is_not(None)).count()
|
||||
|
||||
print("\n📊 Database Status:")
|
||||
print(f" Merchants: {merchant_count}")
|
||||
|
||||
Reference in New Issue
Block a user