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
This commit is contained in:
Automated Action 2025-06-20 12:30:47 +00:00
parent f2b2889ea1
commit a8b6d5b972
3 changed files with 3 additions and 3 deletions

View File

@ -28,7 +28,7 @@ def upgrade() -> None:
sa.Column("customer_email", sa.String(), nullable=True), sa.Column("customer_email", sa.String(), nullable=True),
sa.Column("customer_name", sa.String(), nullable=True), sa.Column("customer_name", sa.String(), nullable=True),
sa.Column("description", 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( sa.Column(
"created_at", "created_at",
sa.DateTime(timezone=True), sa.DateTime(timezone=True),

View File

@ -14,7 +14,7 @@ class Payment(Base):
customer_email = Column(String, index=True) customer_email = Column(String, index=True)
customer_name = Column(String) customer_name = Column(String)
description = 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()) created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now()) updated_at = Column(DateTime(timezone=True), onupdate=func.now())
is_webhook_processed = Column(Boolean, default=False) is_webhook_processed = Column(Boolean, default=False)

View File

@ -71,7 +71,7 @@ class StripeService:
customer_email=customer_email, customer_email=customer_email,
customer_name=customer_name, customer_name=customer_name,
description=payment_intent.description, description=payment_intent.description,
metadata=json.dumps(payment_intent.metadata) payment_metadata=json.dumps(payment_intent.metadata)
if payment_intent.metadata if payment_intent.metadata
else None, else None,
) )