@@ -27,8 +27,7 @@ def _parse_model_slug(value: str, model_slugs: set[str]) -> str: close = difflib.get_close_matches(model_slug, model_slugs, n=1) if close: raise argparse.ArgumentTypeError( - f'NeuronModel со slug "{model_slug}" не найдена. ' - f'Возможно, вы имели в виду: {close[0]}' + f'NeuronModel со slug "{model_slug}" не найдена. Возможно, вы имели в виду: {close[0]}' ) raise argparse.ArgumentTypeError(f'NeuronModel со slug "{model_slug}" не найдена.') @@ -81,11 +80,14 @@ def _build_migration_source( return f"""# Generated by makemigration_payment_features on {datetime.now():%Y-%m-%d %H:%M} import math +import logging from decimal import Decimal from django.db import migrations from django.db.models import Max +logger = logging.getLogger(__name__) + def {func_name}(apps, schema_editor): PaymentPlan = apps.get_model('payments', 'PaymentPlan') @@ -95,7 +97,11 @@ def {func_name}(apps, schema_editor): price = Decimal('{price}') measurement_unit = '{measurement_unit}' price_threshold = {price_threshold} - model = NeuronModel.objects.get(slug='{model_slug}') + try: + model = NeuronModel.objects.get(slug='{model_slug}') + except NeuronModel.DoesNotExist: + logger.warning('The model %s was not found. Migration will do nothing.', '{model_slug}') + return category = model.category max_order_by_plan_id = {{ @@ -247,4 +253,3 @@ class Command(BaseCommand): return int(raw) except ValueError: self.stderr.write('Введите целое число.') - @@ -1,11 +1,14 @@ # Generated by makemigration_payment_features on 2026-07-28 15:33 import math +import logging from decimal import Decimal from django.db import migrations from django.db.models import Max +logger = logging.getLogger(__name__) + def add_flux_3_payment_features(apps, schema_editor): PaymentPlan = apps.get_model('payments', 'PaymentPlan') @@ -15,7 +18,11 @@ def add_flux_3_payment_features(apps, schema_editor): price = Decimal('9.5') measurement_unit = 'file' price_threshold = 0 - model = NeuronModel.objects.get(slug='flux_3') + try: + model = NeuronModel.objects.get(slug='flux_3') + except NeuronModel.DoesNotExist: + logger.warning('The model %s was not found. Migration will do nothing.', 'flux_3') + return category = model.category max_order_by_plan_id = { @@ -49,7 +56,6 @@ def add_flux_3_payment_features(apps, schema_editor): class Migration(migrations.Migration): - dependencies = [ ('payments', '0031_remove_paymentmethod_attempts_and_more'), ] @@ -1,11 +1,14 @@ # Generated by makemigration_payment_features on 2026-07-28 15:34 import math +import logging from decimal import Decimal from django.db import migrations from django.db.models import Max +logger = logging.getLogger(__name__) + def add_grok_image_ultra_payment_features(apps, schema_editor): PaymentPlan = apps.get_model('payments', 'PaymentPlan') @@ -15,7 +18,11 @@ def add_grok_image_ultra_payment_features(apps, schema_editor): price = Decimal('45') measurement_unit = 'file' price_threshold = 0 - model = NeuronModel.objects.get(slug='grok_image_ultra') + try: + model = NeuronModel.objects.get(slug='grok_image_ultra') + except NeuronModel.DoesNotExist: + logger.warning('The model %s was not found. Migration will do nothing.', 'grok_image_ultra') + return category = model.category max_order_by_plan_id = { @@ -49,7 +56,6 @@ def add_grok_image_ultra_payment_features(apps, schema_editor): class Migration(migrations.Migration): - dependencies = [ ('payments', '0032_add_flux_3_payment_features'), ] @@ -1,11 +1,14 @@ # Generated by makemigration_payment_features on 2026-07-28 17:27 +import logging import math from decimal import Decimal from django.db import migrations from django.db.models import Max +logger = logging.getLogger(__name__) + def add_flux_payment_features(apps, schema_editor): PaymentPlan = apps.get_model('payments', 'PaymentPlan') @@ -15,6 +18,7 @@ def add_flux_payment_features(apps, schema_editor): try: model = NeuronModel.objects.get(slug='flux') except NeuronModel.DoesNotExist: + logger.warning('The model %s was not found. Migration will do nothing.', 'flux') return price = Decimal('9.5') @@ -53,7 +57,6 @@ def add_flux_payment_features(apps, schema_editor): class Migration(migrations.Migration): - dependencies = [ ('payments', '0033_add_grok_image_ultra_payment_features'), ]