tortoise / aerich

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

Aerich wants to alter instead of create new field. #116

Closed DusanKovacevic94 closed 3 years ago

DusanKovacevic94 commented 3 years ago
    exp = fields.FloatField(null=False, default=0)
    lvl = fields.IntField(null=False, default=0)

is updated to

    exp = fields.FloatField(null=False, default=0)
    lvl = fields.IntField(null=False, default=0)
    voice_exp = fields.FloatField(null=False, default=0)
    voice_lvl = fields.IntField(null=False, default=0)

Migrate creates this

ALTER TABLE `users` RENAME COLUMN `exp` TO `voice_exp`;
ALTER TABLE `users` RENAME COLUMN `lvl` TO `voice_lvl`;
long2ice commented 3 years ago

So why not choice False when prompt rename?

DusanKovacevic94 commented 3 years ago

Oh, I don't know why I thought this will delete exp and lvl to create voice_exp and voice_lvl.

DusanKovacevic94 commented 3 years ago

And if aerich guess you are renaming a column, it will ask Rename {old_column} to {new_column} [True], you can choice True to rename column without column drop, or choice False to drop column then create, note that the after maybe lose data. This part of the readme confused me.

long2ice commented 3 years ago

This can be optimizing