prop_firm / set_payment_source_migration.py
zainkhan557
fresh initial commit
a63a304
Raw
History Blame Contribute Delete
1.21 kB
"""
set_payment_source_migration.py
────────────────────────────────
Yeh script payments table mein "source" column add karta hai
(SAFEPAY ya ADMIN_ASSIGNED batane ke liye).
Ek baar chalao β€” project root se:
python set_payment_source_migration.py
"""
import sqlite3
import os
DB_PATH = os.path.join(os.path.dirname(__file__), "prop_platform.db")
def column_exists(cursor, table, column):
cursor.execute(f"PRAGMA table_info({table})")
cols = [row[1] for row in cursor.fetchall()]
return column in cols
def run_migration():
if not os.path.exists(DB_PATH):
print(f"❌ Database not found at: {DB_PATH}")
return
conn = sqlite3.connect(DB_PATH)
cur = conn.cursor()
if not column_exists(cur, "payments", "source"):
cur.execute("ALTER TABLE payments ADD COLUMN source TEXT DEFAULT 'SAFEPAY'")
print("βœ… payments.source column added (default='SAFEPAY')")
else:
print("ℹ️ payments.source already exists β€” skip")
conn.commit()
conn.close()
print("\nπŸŽ‰ Migration complete! Server restart karo.")
if __name__ == "__main__":
run_migration()