Slugs feature migrations
This commit is contained in:
parent
6420a676df
commit
73a858cc8c
38
apps/collection/migrations/0013_auto_20190923_1505.py
Normal file
38
apps/collection/migrations/0013_auto_20190923_1505.py
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Generated by Django 2.2.4 on 2019-09-23 15:05
|
||||||
|
from django.core.validators import EMPTY_VALUES
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
from collection.models import Collection
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_data_forward(apps, schema_editor):
|
||||||
|
for instance in Collection.objects.all():
|
||||||
|
if instance.slug in EMPTY_VALUES:
|
||||||
|
instance.slug = None
|
||||||
|
instance.save(update_fields=['slug'])
|
||||||
|
|
||||||
|
def migrate_data_backward(apps, schema_editor):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('collection', '0012_collection_slug'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='collection',
|
||||||
|
name='slug',
|
||||||
|
field=models.SlugField(null=True, verbose_name='Collection slug'),
|
||||||
|
),
|
||||||
|
migrations.RunPython(
|
||||||
|
migrate_data_forward,
|
||||||
|
migrate_data_backward,
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='collection',
|
||||||
|
name='slug',
|
||||||
|
field=models.SlugField(null=True, unique=True, verbose_name='Collection slug'),
|
||||||
|
),
|
||||||
|
]
|
||||||
39
apps/establishment/migrations/0030_auto_20190923_1505.py
Normal file
39
apps/establishment/migrations/0030_auto_20190923_1505.py
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Generated by Django 2.2.4 on 2019-09-23 15:05
|
||||||
|
from django.core.validators import EMPTY_VALUES
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
from establishment.models import Establishment
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_data_forward(apps, schema_editor):
|
||||||
|
for instance in Establishment.objects.all():
|
||||||
|
if instance.slug in EMPTY_VALUES:
|
||||||
|
instance.slug = None
|
||||||
|
instance.save(update_fields=['slug'])
|
||||||
|
|
||||||
|
def migrate_data_backward(apps, schema_editor):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('establishment', '0029_establishment_slug'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='establishment',
|
||||||
|
name='slug',
|
||||||
|
field=models.SlugField(null=True, verbose_name='Establishment slug'),
|
||||||
|
),
|
||||||
|
migrations.RunPython(
|
||||||
|
migrate_data_forward,
|
||||||
|
migrate_data_backward,
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='establishment',
|
||||||
|
name='slug',
|
||||||
|
field=models.SlugField(unique=True, null=True, verbose_name='Establishment slug'),
|
||||||
|
),
|
||||||
|
]
|
||||||
38
apps/news/migrations/0011_auto_20190923_1505.py
Normal file
38
apps/news/migrations/0011_auto_20190923_1505.py
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Generated by Django 2.2.4 on 2019-09-23 15:05
|
||||||
|
from django.core.validators import EMPTY_VALUES
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
from news.models import News
|
||||||
|
|
||||||
|
|
||||||
|
def migrate_data_forward(apps, schema_editor):
|
||||||
|
for instance in News.objects.all():
|
||||||
|
if instance.slug in EMPTY_VALUES:
|
||||||
|
instance.slug = None
|
||||||
|
instance.save(update_fields=['slug'])
|
||||||
|
|
||||||
|
def migrate_data_backward(apps, schema_editor):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('news', '0010_news_slug'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='news',
|
||||||
|
name='slug',
|
||||||
|
field=models.SlugField(null=True, verbose_name='News slug'),
|
||||||
|
),
|
||||||
|
migrations.RunPython(
|
||||||
|
migrate_data_forward,
|
||||||
|
migrate_data_backward,
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='news',
|
||||||
|
name='slug',
|
||||||
|
field=models.SlugField(null=True, unique=True, verbose_name='News slug'),
|
||||||
|
),
|
||||||
|
]
|
||||||
Loading…
Reference in New Issue
Block a user