fina/migrations/add_monthly_budget.py
2025-12-26 00:52:56 +00:00

28 lines
917 B
Python
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
Migration: Add monthly_budget column to users table
Run this with: python migrations/add_monthly_budget.py
"""
from app import create_app, db
def migrate():
app = create_app()
with app.app_context():
try:
# Check if column exists
from sqlalchemy import inspect
inspector = inspect(db.engine)
columns = [col['name'] for col in inspector.get_columns('users')]
if 'monthly_budget' not in columns:
db.engine.execute('ALTER TABLE users ADD COLUMN monthly_budget FLOAT DEFAULT 0.0')
print("✅ Successfully added monthly_budget column to users table")
else:
print(" Column monthly_budget already exists")
except Exception as e:
print(f"❌ Migration failed: {e}")
raise
if __name__ == '__main__':
migrate()