delete fix
This commit is contained in:
parent
9fcd76a3db
commit
80d84f64aa
|
|
@ -95,9 +95,10 @@ func (ProductFlat) TableName() string {
|
|||
|
||||
func DeleteProducts(db *gorm.DB) error {
|
||||
//todo delete from elastico
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Minute)
|
||||
defer cancel()
|
||||
qb := "DELETE p.* FROM products p, order_items oi WHERE p.id NOT IN (select product_id from wishlist) AND p.id NOT IN (select product_id from order_items) AND p.id NOT IN (select parent_id from order_items)"
|
||||
//qb := "DELETE FROM products WHERE id NOT IN (select product_id as id from wishlist) AND id NOT IN (select product_id as id from order_items) AND id NOT IN (select parent_id as idfrom order_items);"
|
||||
qb := "DELETE p FROM products p LEFT JOIN wishlist w on p.id = w.product_id LEFT JOIN order_items oi ON p.id = oi.product_id LEFT JOIN order_items op ON p.id = op.parent_id WHERE w.id IS NULL AND oi.id IS NULL AND op.id IS NULL;"
|
||||
return db.WithContext(ctx).Exec(qb).Error
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue