tortoise / aerich

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

Adding not null OneToOneRelation (tortoise) not working #211

Open JeffryCA opened 2 years ago

JeffryCA commented 2 years ago

Setup: 1) Create 2 models and db (postgres) 2) init migrations ... 3) add a fields.OneToOneRelation(..., null=False) to one of the models 4) migrate 5) upgrade

Results in: -- upgrade -- ALTER TABLE "table1" ADD "foreign_key" UUID NOT NULL UNIQUE; -- downgrade -- ALTER TABLE "table1" DROP COLUMN "foreign_key";

This however does not enforce the foreign key relationship to table 2! In other words one can add rows with unique random values without errors.