35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
from django.db import migrations, models
|
|
|
|
|
|
def backfill_gonggao_page_key(apps, schema_editor):
|
|
Gonggao = apps.get_model('config', 'Gonggao')
|
|
for row in Gonggao.objects.filter(page_key='').only('id'):
|
|
row.page_key = 'order_pool'
|
|
row.save(update_fields=['page_key'])
|
|
for row in Gonggao.objects.filter(page_key__isnull=True).only('id'):
|
|
row.page_key = 'order_pool'
|
|
row.save(update_fields=['page_key'])
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('config', '0007_platform_income_log'),
|
|
]
|
|
|
|
operations = [
|
|
migrations.AddField(
|
|
model_name='gonggao',
|
|
name='page_key',
|
|
field=models.CharField(
|
|
db_index=True, default='order_pool', max_length=32,
|
|
verbose_name='页面标识(order_pool/accept_order/merchant_home)',
|
|
),
|
|
),
|
|
migrations.RunPython(backfill_gonggao_page_key, migrations.RunPython.noop),
|
|
migrations.AlterUniqueTogether(
|
|
name='gonggao',
|
|
unique_together={('club_id', 'page_key')},
|
|
),
|
|
]
|