0.4.2 - Early implementation of SLMs. WIP.
This commit is contained in:
45
scripts/remove_test_data_from_prod.py
Normal file
45
scripts/remove_test_data_from_prod.py
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Remove test SLMs and modems from PRODUCTION database
|
||||
"""
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
from backend.models import RosterUnit
|
||||
|
||||
# PRODUCTION database
|
||||
PROD_DB_URL = "sqlite:///./data/seismo_fleet.db"
|
||||
|
||||
def remove_test_data():
|
||||
engine = create_engine(PROD_DB_URL, connect_args={"check_same_thread": False})
|
||||
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
db = SessionLocal()
|
||||
|
||||
# IDs to remove
|
||||
test_slm_ids = ["nl43-001", "nl43-002", "nl53-001", "nl43-003"]
|
||||
test_modem_ids = ["modem-001", "modem-002", "modem-003", "modem-004"]
|
||||
|
||||
all_test_ids = test_slm_ids + test_modem_ids
|
||||
|
||||
removed = []
|
||||
for unit_id in all_test_ids:
|
||||
unit = db.query(RosterUnit).filter_by(id=unit_id).first()
|
||||
if unit:
|
||||
db.delete(unit)
|
||||
removed.append(unit_id)
|
||||
print(f"Removed {unit_id}")
|
||||
|
||||
if removed:
|
||||
db.commit()
|
||||
print(f"\nRemoved {len(removed)} test units from PRODUCTION database")
|
||||
else:
|
||||
print("No test units found in production database")
|
||||
|
||||
db.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("Removing test data from PRODUCTION database...")
|
||||
print("=" * 60)
|
||||
remove_test_data()
|
||||
print("=" * 60)
|
||||
print("Done! Production database is clean.")
|
||||
Reference in New Issue
Block a user