import sqlite3
c = sqlite3.connect('db.sqlite3')
cur = c.cursor()
# Delete erp migration records
cur.execute("DELETE FROM django_migrations WHERE app='erp'")
# Drop all erp tables
for row in cur.execute("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'erp_%'"):
    cur.execute(f"DROP TABLE IF EXISTS {row[0]}")
c.commit()
print("Done - erp migration state cleared and tables dropped")
