migration repaire

This commit is contained in:
javad committed 2026-10-08 18:09:12 +03:30
1 parent c8d45dd07c
commit 56d8760613
11 files changed
+492 -5064

No files matched your search

+10 -4
View File
@@ -272,16 +272,22 @@ class AuthRegressionTests(RegressionFixtures):
self.assertFalse(self.role.customer_panel)
self.assertEqual(self.post('token/refresh/', {'refresh': tokens['refresh']}).status_code, 401)
def test_duplicate_migration_audits_before_changing_any_data(self):
def test_duplicate_migration_quarantines_without_deleting_customers(self):
import importlib
from django.apps import apps
from django.db import connection
duplicate = Customer.objects.create(name_family='Legacy', mobile=989123456789, sys_ws=self.workspace)
migration = importlib.import_module('apps.customer.migrations.0008_customer_mobile_unique')
with self.assertRaises(RuntimeError):
migration.check_and_normalize_mobiles(apps, Mock(connection=connection))
migration.check_and_normalize_mobiles(apps, Mock(connection=connection))
duplicate.refresh_from_db()
self.assertEqual(duplicate.mobile, 989123456789)
self.customer.refresh_from_db()
self.role.refresh_from_db()
self.assertIsNone(duplicate.mobile)
self.assertIsNone(self.customer.mobile)
self.assertIsNone(self.customer.cuser_role_id)
self.assertFalse(self.role.customer_panel)
from apps.customer.models import MobileConflict
self.assertEqual(MobileConflict.objects.get(record_id=duplicate.pk).original_mobile, 989123456789)
def test_migration_normalizes_legacy_country_prefix(self):
import importlib