aerich
aerich copied to clipboard
aerich doesn't respect default in TextField
Add the text field
text = fields.TextField(default='')
run aerich migrate
the result is
{
"upgrade": [
"ALTER TABLE \"company\" ADD \"text\" TEXT NOT NULL"
],
"downgrade": [
"ALTER TABLE \"company\" DROP COLUMN \"text\""
]
}
see https://stackoverflow.com/questions/28002029/mysql-default-value-for-text-column-behaving-erratically-why
That's a 14 years old bug in MySQL, according to https://stackoverflow.com/questions/3466872/why-cant-a-text-column-have-a-default-value-in-mysql Ok, I see a reason why it is implemented as is.
But it is impossible to add TextField to existing table without specifying null=True or default=''. And nullable text (and char) fields is a bad practice, because you would have two different empty values (Null and empty string).
So it can be done with normal RDBMS, like PostgreSQL.