tortoise / aerich

A database migrations tool for TortoiseORM, ready to production.
https://github.com/tortoise/aerich
Apache License 2.0
820 stars 94 forks source link

MySQL: Data too long for column 'content' at row 1" for aerich init-db and aerich upgrade #154

Closed saintlyzero closed 3 years ago

saintlyzero commented 3 years ago

Aerich version - 0.5.3 Databae - MySQL 8 I have a total of 22 tables, and when I do aerich init-db I'm getting an error

tortoise.exceptions.OperationalError: (1406, "Data too long for column 'content' at row 1")

The new content field to store the entire migration JSON in Aerich overflows the MySQL text dataype limit of 64 Kilobytes

Aerich.create(
        version=version, 
        app=app, 
        content=get_models_describe(app),
 )

I manually changed the datatype of content to JSON in MySQL, and it worked

To make this the default behavior we'll have to update the Tortoise ORM JSONField which always stores it as a Text field for MySQL. I think this is because MySQL introduced JSON datatype from MySQL 8.0

@long2ice any workarounds to fix this?

long2ice commented 3 years ago

Latest dev branch use JSON already