fixes for ai and iamge related models bacekedn

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-10 05:11:24 +00:00
parent 0c693dc1cc
commit 975eab46cf
9 changed files with 156 additions and 176 deletions

View File

@@ -1,78 +0,0 @@
# Generated migration for adding image size fields to AIModelConfig
from django.db import migrations, models
def populate_image_sizes(apps, schema_editor):
"""Populate image sizes based on model name"""
AIModelConfig = apps.get_model('billing', 'AIModelConfig')
# Model-specific sizes
model_sizes = {
'runware:97@1': {
'landscape_size': '1280x768',
'square_size': '1024x1024',
'valid_sizes': ['1024x1024', '1280x768', '768x1280'],
},
'bria:10@1': {
'landscape_size': '1344x768',
'square_size': '1024x1024',
'valid_sizes': ['1024x1024', '1344x768', '768x1344'],
},
'google:4@2': {
'landscape_size': '1376x768',
'square_size': '1024x1024',
'valid_sizes': ['1024x1024', '1376x768', '768x1376'],
},
'dall-e-3': {
'landscape_size': '1792x1024',
'square_size': '1024x1024',
'valid_sizes': ['1024x1024', '1792x1024', '1024x1792'],
},
'dall-e-2': {
'landscape_size': '1024x1024',
'square_size': '1024x1024',
'valid_sizes': ['256x256', '512x512', '1024x1024'],
},
}
for model_name, sizes in model_sizes.items():
AIModelConfig.objects.filter(
model_name=model_name,
model_type='image'
).update(**sizes)
def reverse_migration(apps, schema_editor):
"""Clear image size fields"""
AIModelConfig = apps.get_model('billing', 'AIModelConfig')
AIModelConfig.objects.filter(model_type='image').update(
landscape_size=None,
square_size='1024x1024',
valid_sizes=[],
)
class Migration(migrations.Migration):
dependencies = [
('billing', '0026_populate_aimodel_credits'),
]
operations = [
migrations.AddField(
model_name='aimodelconfig',
name='landscape_size',
field=models.CharField(blank=True, help_text="Landscape image size for this model (e.g., '1792x1024', '1280x768')", max_length=20, null=True),
),
migrations.AddField(
model_name='aimodelconfig',
name='square_size',
field=models.CharField(blank=True, default='1024x1024', help_text="Square image size for this model (e.g., '1024x1024')", max_length=20),
),
migrations.AddField(
model_name='aimodelconfig',
name='valid_sizes',
field=models.JSONField(blank=True, default=list, help_text="List of valid sizes for this model (e.g., ['1024x1024', '1792x1024'])"),
),
migrations.RunPython(populate_image_sizes, reverse_migration),
]

View File

@@ -0,0 +1,15 @@
# Generated manually - Add image size fields to AIModelConfig
from django.db import migrations, models
class Migration(migrations.Migration):
"""Add landscape_size, square_size, and valid_sizes fields to AIModelConfig."""
dependencies = [
('billing', '0029_add_webhook_event_and_manual_reference_constraint'),
]
operations = [
# Fields already added via direct SQL, just mark as noop
# This ensures the model matches the database schema
]