[英]Django Port from Postgres to MariaDB manage.py migrate error SQL Syntax Error 1064
我正在將我的 Django 應用程序從 Postgres 移植到 MariaDB 並在執行遷移步驟時收到以下錯誤:
django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[20] NOT NULL, `last_update` datetime(6) NOT NULL, `commited` bool NOT NULL, ...' at line 1")
創建了所有標准 Django 表,並創建了我的第一個 model 表。 但我永遠不會超越那一步。
我的模型都是以下風格:
class Country(models.Model):
name = models.CharField(max_length=100, unique=True,
help_text=_('This is the full name of the country'),
verbose_name=_('Country'),
)
alternate_name = models.CharField(max_length=100, null=True, blank=True,
help_text=_('This is the alternate name - often abbreviation - of the country'),
verbose_name=_('Country alternate name'),
)
iso_numeric = models.DecimalField(max_digits=3, decimal_places=0,null=True,
help_text=_('This is the ISO numeric code of the country'),
verbose_name=_('ISO numeric code'),
)
iso_alpha = models.CharField(max_length=3, null=True, blank=True,
help_text=_('This is the ISO alpha code of the country'),
verbose_name=_('ISO alpha code'),
)
last_update = models.DateTimeField(auto_now_add=True,
help_text=_('This is the timestamp of the last update'),
verbose_name=_('Timestamp last update'),
)
last_update_id = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.SET_NULL, editable=False,
help_text=_('This is the user making last update'),
verbose_name=_('User making last update'),
)
committed = models.BooleanField(default=False, editable=False,
help_text=
_('This field is set to false once record is created until admin has committed it'),
verbose_name=_('Committed'),
)
我已經看到可能涉及 DateTime 或 Boolean 字段的類似問題。 但是,即使我將它們注釋掉,我也會得到相同的結果。
mysql Ver 15.1 Distrib 10.4.13-MariaDB,適用於使用 readline 5.1 的 osx10.15 (x86_64)
我正在使用 mysqlclient 1.4.6。
任何指針? 謝謝,馬丁
生產的 Django sql 包含一個陣列。 以下 model 字段:
alternate_name = models.CharField(max_length=60, blank=True, null=True,
help_text=_('This is a list of alternate grape names'),
verbose_name=_('Alternate grape names'),
)
導致以下 sql:
`alternate_name` varchar(30)[20] NOT NULL,
我已更改 sql 刪除數組信息並手動運行查詢。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.