Files
membership-be/migrate_add_manual_payment.py
Koncept Kit 6ef7685ade first commit
2025-12-05 16:43:37 +07:00

41 lines
1.5 KiB
Python

"""
Migration script to add manual payment columns to subscriptions table.
Run this once to update the database schema.
"""
from database import engine
from sqlalchemy import text
def add_manual_payment_columns():
"""Add manual payment columns to subscriptions table"""
migrations = [
"ALTER TABLE subscriptions ADD COLUMN IF NOT EXISTS manual_payment BOOLEAN NOT NULL DEFAULT FALSE",
"ALTER TABLE subscriptions ADD COLUMN IF NOT EXISTS manual_payment_notes TEXT",
"ALTER TABLE subscriptions ADD COLUMN IF NOT EXISTS manual_payment_admin_id UUID REFERENCES users(id)",
"ALTER TABLE subscriptions ADD COLUMN IF NOT EXISTS manual_payment_date TIMESTAMP",
"ALTER TABLE subscriptions ADD COLUMN IF NOT EXISTS payment_method VARCHAR"
]
try:
print("Adding manual payment columns to subscriptions table...")
with engine.connect() as conn:
for sql in migrations:
print(f" Executing: {sql[:60]}...")
conn.execute(text(sql))
conn.commit()
print("✅ Migration completed successfully!")
print("\nAdded columns:")
print(" - manual_payment (BOOLEAN)")
print(" - manual_payment_notes (TEXT)")
print(" - manual_payment_admin_id (UUID)")
print(" - manual_payment_date (TIMESTAMP)")
print(" - payment_method (VARCHAR)")
except Exception as e:
print(f"❌ Migration failed: {e}")
raise
if __name__ == "__main__":
add_manual_payment_columns()