diff --git a/apps/location/transfer.py b/apps/location/transfer.py index 2ae7411b..e9b51978 100644 --- a/apps/location/transfer.py +++ b/apps/location/transfer.py @@ -8,18 +8,65 @@ field[0] - название аргумента field[1] - название поля в таблице legacy Опционально: field[2] - тип данных для преобразования +NOTE: среди legacy таблиц совпадение для таблицы Address не найдено (Возможно для Address подходит Locations в legacy) """ + +Country = { + "dependencies": None, + "fields": { + "Cities": { + "code": "country_code_2", + } + } +} + + +Region = { + "dependencies": ("Country", "Region"), + "fields": { + # нету аналога для поля name + "Cities": { + "code": "region_code", + }, + "ForeignKeys": { + "parent_region": "Region", + "country": "Country" + } + } +} + + City = { "dependencies": ("Country", "Region"), "fields": { "Cities": { - "coordinates": (("lat", "latitude", "Boolean"), ("long", "longtitude")), - "code": "country_code_2" + "coordinates": (("lat", "latitude"), ("long", "longitude")), + "code": "country_code_2", + "postal_code": "zip_code", + "is_island": ("is_island", "Boolean") }, "CityNames": { "name": "name", - + }, + "ForeignKeys": { + "region": "Region", + "country": "Country" } } -} \ No newline at end of file +} + + +Address = { + "dependencies": ("City",), + "fields": { + # нету аналога для поля number + "Locations": { + "postal_code": "zip_code", + "coordinates": (("lat", "latitude"), ("long", "longitude")) + }, + "ForeignKeys": { + "city": "City" + } + } +} diff --git a/apps/transfer/models.py b/apps/transfer/models.py index 4a0931d8..8c8cbb1f 100644 --- a/apps/transfer/models.py +++ b/apps/transfer/models.py @@ -68,3 +68,26 @@ class CityPhotos(MigrateMixin): class Meta: managed = False db_table = 'city_photos' + + +class Locations(models.Model): + using = 'legacy' + + country_code = models.CharField(max_length=3) + region_code = models.CharField(max_length=3, blank=True, null=True) + subregion_code = models.CharField(max_length=3, blank=True, null=True) + zip_code = models.CharField(max_length=9, blank=True, null=True) + district_name = models.CharField(max_length=255, blank=True, null=True) + longitude = models.DecimalField(max_digits=10, decimal_places=6, blank=True, null=True) + latitude = models.DecimalField(max_digits=10, decimal_places=6, blank=True, null=True) + timezone = models.CharField(max_length=32, blank=True, null=True) + transportation = models.CharField(max_length=255, blank=True, null=True) + address = models.TextField(blank=True, null=True) + city = models.ForeignKey(Cities, models.DO_NOTHING, blank=True, null=True) + map_ref = models.CharField(max_length=255, blank=True, null=True) + created_at = models.DateTimeField() + updated_at = models.DateTimeField() + + class Meta: + managed = False + db_table = 'locations'