fix: screen uses court_number, seed resets sequences

This commit is contained in:
Forge
2026-03-19 01:22:12 +08:00
parent 1be2ba729e
commit 7a4c573d1c
2 changed files with 13 additions and 2 deletions

View File

@@ -23,6 +23,14 @@ def clear_data(db: Session):
db.query(Court).delete()
db.query(Player).delete()
db.commit()
# Reset sequences
for table in ['players', 'courts', 'bookings', 'matches', 'match_players',
'tournaments', 'tournament_entries', 'tournament_matches']:
try:
db.execute(__import__('sqlalchemy').text(f"ALTER SEQUENCE {table}_id_seq RESTART WITH 1"))
except Exception:
pass
db.commit()
print("Cleared existing data")