fixes fixes fixes tenaancy
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
# Generated migration for Payment status simplification
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def migrate_payment_statuses(apps, schema_editor):
|
||||
"""
|
||||
Migrate old payment statuses to new simplified statuses:
|
||||
- pending, processing, completed, cancelled → map to new statuses
|
||||
"""
|
||||
Payment = apps.get_model('billing', 'Payment')
|
||||
|
||||
# Map old statuses to new statuses
|
||||
status_mapping = {
|
||||
'pending': 'pending_approval', # Treat as pending approval
|
||||
'processing': 'pending_approval', # Treat as pending approval
|
||||
'completed': 'succeeded', # completed = succeeded
|
||||
'cancelled': 'failed', # cancelled = failed
|
||||
# Keep existing: pending_approval, succeeded, failed, refunded
|
||||
}
|
||||
|
||||
for old_status, new_status in status_mapping.items():
|
||||
Payment.objects.filter(status=old_status).update(status=new_status)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('billing', '0006_auto_20251209_payment_workflow'), # Adjust to your latest migration
|
||||
]
|
||||
|
||||
operations = [
|
||||
# Update status choices (Django will handle this in model)
|
||||
migrations.RunPython(migrate_payment_statuses, reverse_code=migrations.RunPython.noop),
|
||||
]
|
||||
Reference in New Issue
Block a user