99 lines
3.4 KiB
Python
99 lines
3.4 KiB
Python
# Generated by Django 2.2.7 on 2019-11-21 12:36
|
|
|
|
import django.contrib.postgres.fields
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
import utils.models
|
|
|
|
|
|
def copy_country_code(apps, schema_editor):
|
|
Country = apps.get_model('location', 'Country')
|
|
to_update = []
|
|
for country in Country.objects.all():
|
|
if country.code:
|
|
country.code_2 = country.code
|
|
to_update.append(country)
|
|
Country.objects.bulk_update(to_update, ['code_2', ])
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('location', '0030_auto_20191120_1010'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name='city',
|
|
name='map1',
|
|
field=models.CharField(blank=True, max_length=255, null=True),
|
|
),
|
|
migrations.AddField(
|
|
model_name='city',
|
|
name='map2',
|
|
field=models.CharField(blank=True, max_length=255, null=True),
|
|
),
|
|
migrations.AddField(
|
|
model_name='city',
|
|
name='map_ref',
|
|
field=models.CharField(blank=True, max_length=255, null=True),
|
|
),
|
|
migrations.AddField(
|
|
model_name='city',
|
|
name='mysql_id',
|
|
field=models.IntegerField(blank=True, default=None, null=True),
|
|
),
|
|
migrations.AddField(
|
|
model_name='city',
|
|
name='name_translated',
|
|
field=utils.models.TJSONField(blank=True, default=None, help_text='{"en-GB":"some text"}', null=True, verbose_name='Translated name'),
|
|
),
|
|
migrations.AddField(
|
|
model_name='city',
|
|
name='situation',
|
|
field=models.CharField(blank=True, max_length=255, null=True),
|
|
),
|
|
migrations.AddField(
|
|
model_name='country',
|
|
name='mysql_ids',
|
|
field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), blank=True, null=True, size=None),
|
|
),
|
|
migrations.AddField(
|
|
model_name='region',
|
|
name='mysql_ids',
|
|
field=django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), blank=True, null=True, size=None),
|
|
),
|
|
migrations.AlterField(
|
|
model_name='city',
|
|
name='gallery',
|
|
field=models.ManyToManyField(blank=True, through='location.CityGallery', to='gallery.Image'),
|
|
),
|
|
migrations.AlterField(
|
|
model_name='city',
|
|
name='region',
|
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='location.Region', verbose_name='parent region'),
|
|
),
|
|
# -- fix incorrect removal of uniqueness constraint code field
|
|
migrations.AddField(
|
|
model_name='country',
|
|
name='code_2',
|
|
field=models.CharField(max_length=255, null=True)
|
|
),
|
|
migrations.RunPython(copy_country_code, migrations.RunPython.noop),
|
|
migrations.RemoveField(
|
|
model_name='country',
|
|
name='code',
|
|
),
|
|
migrations.RenameField(
|
|
model_name='country',
|
|
old_name='code_2',
|
|
new_name='code',
|
|
),
|
|
migrations.AlterField(
|
|
model_name='country',
|
|
name='code',
|
|
field=models.CharField(max_length=255, verbose_name='Code'),
|
|
),
|
|
# fix incorrect removal of uniqueness constraint code field --
|
|
]
|