Closed anfimovdm closed 9 months ago
@metalefty
We have a flavour config here with repositories and other data.
Sometimes users can remove some repositories from this config.
And if we run our manage_flavours
script with the -U
flag repositories that were removed from that config will remain in our database.
So, we need to make changes in the manage_flavours
script to keep only actual flavours in our database.
Thanks for the detail!
We need to delete flavours not only from platform_flavours
table because there's foreign key constraint.
I'm going to delete relation from platform_flavour_repository
.
What about repositories
?
And if we run our manage_flavours script with the -U flag repositories that were removed from that config will remain in our database.
As far as I understand this comment, need to delete repos.
Yes, we need to remove all entities (such as repositories
and platform_flavour_repository
) related to platform_flavour
Thanks I already implemented simple deletion. I'm working on deleting related entities now.
sqlalchemy.exc.IntegrityError: (sqlalchemy.dialects.postgresql.asyncpg.IntegrityError) <class 'asyncpg.exceptions.ForeignKeyViolationError'>: update or delete on table "platform_flavours" violates foreign key constraint "platform_flavour_repository_flavour_id_fkey" on table "platform_flavour_repository"
DETAIL: Key (id)=(1) is still referenced from table "platform_flavour_repository".
[SQL: DELETE FROM platform_flavours WHERE platform_flavours.id = %s]
I'm still not sure how to perform this in SQLAlchemy and looking into that.
DELETE FROM repositories WHERE id IN (SELECT repository_id FROM platform_flavour_repository WHERE flavour_id=1);
DELETE FROM platform_flavour_repository WHERE flavour_id=1;
I know how to perform this:
DELETE FROM platform_flavours WHERE id=1;
db.execute(delete(models.PlatformFlavour).where(models.PlatformFlavour.id == pf_id))
Config for flavours. If database have more repos then that config we should delete relation to extra ones from DB. As part of the said script.