Make model which references other model as One2One. One2One is implemented via foreign + unique
Migrate & apply changes to db
Change field type to ForeignKeyField and migrate
Expected results
Upgrade: alter table ... drop constraint <unique_constrait>;
Downgrade: alter table add constraint ...;
Actual results
Upgrade: aerich tries to drop non-existing index (dropping existing one will not work anyway) and then create new foreign key constraint (ignoring already existing)
Downgrade: drop duplicated constraint + CREATE UNIQUE INDEX ...
Environment info
I'm using latest aerich from PyPI (0.7.1) and PostgreSQL 15
What I done to make it happen
Expected results
Upgrade:
alter table ... drop constraint <unique_constrait>;
Downgrade:alter table add constraint ...;
Actual results
Upgrade: aerich tries to drop non-existing index (dropping existing one will not work anyway) and then create new foreign key constraint (ignoring already existing) Downgrade: drop duplicated constraint +
CREATE UNIQUE INDEX ...
Environment info
I'm using latest aerich from PyPI (0.7.1) and PostgreSQL 15