Browse Source

fix: 修改工单迁移文件warining问题

Any fields that are stored with VARCHAR column types may have their max_length restricted to 255 characters if you are using unique=True for the field.
See: https://docs.djangoproject.com/en/3.1/ref/databases/#mysql-character-fields
pull/7496/head
Michael Bai 3 years ago committed by 老广
parent
commit
620834c817
  1. 2
      apps/tickets/migrations/0013_ticket_serial_num.py
  2. 2
      apps/tickets/models/ticket.py

2
apps/tickets/migrations/0013_ticket_serial_num.py

@ -38,7 +38,7 @@ class Migration(migrations.Migration):
migrations.AddField( migrations.AddField(
model_name='ticket', model_name='ticket',
name='serial_num', name='serial_num',
field=models.CharField(max_length=256, null=True, unique=True, verbose_name='Serial number'), field=models.CharField(max_length=128, null=True, unique=True, verbose_name='Serial number'),
), ),
migrations.RunPython(fill_ticket_serial_number), migrations.RunPython(fill_ticket_serial_number),
] ]

2
apps/tickets/models/ticket.py

@ -77,7 +77,7 @@ class Ticket(CommonModelMixin, OrgModelMixin):
'TicketFlow', related_name='tickets', on_delete=models.SET_NULL, null=True, 'TicketFlow', related_name='tickets', on_delete=models.SET_NULL, null=True,
verbose_name=_("TicketFlow") verbose_name=_("TicketFlow")
) )
serial_num = models.CharField(max_length=256, unique=True, null=True, verbose_name=_('Serial number')) serial_num = models.CharField(max_length=128, unique=True, null=True, verbose_name=_('Serial number'))
class Meta: class Meta:
ordering = ('-date_created',) ordering = ('-date_created',)

Loading…
Cancel
Save