fix(product, dashboard): manual cleanup of uploaded images (#10254)
* manual cleanup * add changeset * remove thumbnail on deletion
This commit is contained in:
@@ -19,6 +19,12 @@ export class Migration20241122120331 extends Migration {
|
||||
where pi.image_id = i.id;
|
||||
`);
|
||||
|
||||
// Delete orphaned images
|
||||
this.addSql(`
|
||||
delete from "image"
|
||||
where product_id is null;
|
||||
`);
|
||||
|
||||
this.addSql('alter table if exists "image" alter column "product_id" set not null;');
|
||||
this.addSql('alter table if exists "image" add constraint "image_product_id_foreign" foreign key ("product_id") references "product" ("id") on update cascade on delete cascade;');
|
||||
this.addSql('drop table if exists "product_images" cascade;');
|
||||
|
||||
Reference in New Issue
Block a user