Django 2.0.7-执行重命名字段迁移时出现语法错误 [英] Django 2.0.7 - Syntax Error while doing Rename Field migration

查看:195
本文介绍了Django 2.0.7-执行重命名字段迁移时出现语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下Django类:

I've got the following Django class:

class Contacto(models.Model):
    responsable_documento = models.CharField(primary_key=True, max_length=40)
    responsable_tipo_documento = models.CharField(max_length=20)
    responsable_nombre = models.CharField(max_length=50, blank=True)
    responsable_apellido = models.CharField(max_length=60, blank=True)
    responsable_telefono = models.CharField(max_length=20, blank=True)
    responsable_telefono_particular = models.CharField(max_length=20, blank=True)
    responable_email_uno = models.EmailField()
    responsable_email_dos = models.EmailField()
    responsable_email_tres = models.EmailField()
    cueanexo = models.PositiveIntegerField(null=True)

    class Meta:
        unique_together = (
            ('responsable_documento', 'responsable_tipo_documento', 'alumno_documento', 'alumno_tipo_documento'),
        )
        verbose_name_plural = 'contactos'

我正在尝试重命名一些字段:

And I am trying to rename some fields:

class Contacto(models.Model):
    responsable_documento = models.CharField(primary_key=True, max_length=40)
    responsable_tipo_documento = models.CharField(max_length=20)
    responsable_nombre = models.CharField(max_length=50, blank=True)
    responsable_apellido = models.CharField(max_length=60, blank=True)
    responsable_telefono = models.CharField(max_length=20, blank=True)
    responsable_telefono_celular = models.CharField(max_length=20, blank=True)
    responable_email1 = models.EmailField()
    responsable_email2 = models.EmailField()
    responsable_email3 = models.EmailField()
    cue_anexo = models.PositiveIntegerField(null=True)

    class Meta:
        unique_together = (
            ('responsable_documento', 'responsable_tipo_documento', 'alumno_documento', 'alumno_tipo_documento'),
        )
        verbose_name_plural = 'contactos'

这导致以下迁移:

class Migration(migrations.Migration):

    dependencies = [
        ('datos_basicos', '0008_auto_20180813_1505'),
    ]

    operations = [
        migrations.RenameField(
            model_name='contacto',
            old_name='cueanexo',
            new_name='cue_anexo',
        ),
        migrations.RenameField(
            model_name='contacto',
            old_name='responable_email_uno',
            new_name='responable_email1',
        ),
        migrations.RenameField(
            model_name='contacto',
            old_name='responsable_email_dos',
            new_name='responsable_email2',
        ),
        migrations.RenameField(
            model_name='contacto',
            old_name='responsable_email_tres',
            new_name='responsable_email3',
        ),
        migrations.RenameField(
            model_name='contacto',
            old_name='responsable_telefono_particular',
            new_name='responsable_telefono_celular',
        ),
    ]

当我尝试应用上述迁移时,会发生以下错误:

When I try to apply said migration the following error occurs:

Running migrations:
  Applying datos_basicos.0009_auto_20180813_1731...Traceback (most recent call last):
  File "/home/desarrollo/.local/share/virtualenvs/censo_estudiantil-86GgnGcQ/lib/python3.5/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  psycopg2.ProgrammingError: syntax error at or near "WITH ORDINALITY"
  LINE 6:                     FROM unnest(c.conkey) WITH ORDINALITY co...

有人知道什么可能导致此错误吗?

Do anyone know what could be causing this error?

推荐答案

切换到Django 2.1后,我得到了相同的错误消息,更新了我的Postgres版本后,为我解决了这个问题.但是2.1版本中的支持下降了 https://docs.djangoproject. com/en/2.1/releases/2.1/#dropped-support-for-postgresql-9-3

I got the same error message after switching to Django 2.1, updating my Postgres version fixed this for me. But there was a drop of support in the 2.1 release https://docs.djangoproject.com/en/2.1/releases/2.1/#dropped-support-for-postgresql-9-3

这篇关于Django 2.0.7-执行重命名字段迁移时出现语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆