aerich icon indicating copy to clipboard operation
aerich copied to clipboard

Adding not null OneToOneRelation (tortoise) not working

Open JeffryCA opened this issue 3 years ago • 0 comments

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.

JeffryCA avatar Nov 16 '21 17:11 JeffryCA