From a8b6d5b9726df13aa88efdb8d073ae19a690e435 Mon Sep 17 00:00:00 2001 From: Automated Action Date: Fri, 20 Jun 2025 12:30:47 +0000 Subject: [PATCH] Fix SQLAlchemy reserved attribute error - Renamed 'metadata' column to 'payment_metadata' in Payment model - Updated database migration to use new column name - Updated StripeService to use payment_metadata field - Fixed application startup issue caused by reserved attribute name --- alembic/versions/001_initial_migration.py | 2 +- app/models/payment.py | 2 +- app/services/stripe_service.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/alembic/versions/001_initial_migration.py b/alembic/versions/001_initial_migration.py index 8eb612f..ffce039 100644 --- a/alembic/versions/001_initial_migration.py +++ b/alembic/versions/001_initial_migration.py @@ -28,7 +28,7 @@ def upgrade() -> None: sa.Column("customer_email", sa.String(), nullable=True), sa.Column("customer_name", sa.String(), nullable=True), sa.Column("description", sa.String(), nullable=True), - sa.Column("metadata", sa.String(), nullable=True), + sa.Column("payment_metadata", sa.String(), nullable=True), sa.Column( "created_at", sa.DateTime(timezone=True), diff --git a/app/models/payment.py b/app/models/payment.py index d173f55..d223314 100644 --- a/app/models/payment.py +++ b/app/models/payment.py @@ -14,7 +14,7 @@ class Payment(Base): customer_email = Column(String, index=True) customer_name = Column(String) description = Column(String) - metadata = Column(String) # JSON string for additional data + payment_metadata = Column(String) # JSON string for additional data created_at = Column(DateTime(timezone=True), server_default=func.now()) updated_at = Column(DateTime(timezone=True), onupdate=func.now()) is_webhook_processed = Column(Boolean, default=False) diff --git a/app/services/stripe_service.py b/app/services/stripe_service.py index 1f62908..ab7f44d 100644 --- a/app/services/stripe_service.py +++ b/app/services/stripe_service.py @@ -71,7 +71,7 @@ class StripeService: customer_email=customer_email, customer_name=customer_name, description=payment_intent.description, - metadata=json.dumps(payment_intent.metadata) + payment_metadata=json.dumps(payment_intent.metadata) if payment_intent.metadata else None, )