fix(): product image missing index (#13466)
**What** Add product image imssing index
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/product": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix(): product image missing index
|
||||||
@@ -1189,6 +1189,33 @@
|
|||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_product_image_url\" ON \"image\" (url) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_product_image_url\" ON \"image\" (url) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_product_image_rank",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_product_image_rank\" ON \"image\" (rank) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_product_image_url_rank_product_id",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_product_image_url_rank_product_id\" ON \"image\" (url, rank, product_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_product_image_rank_product_id",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"constraint": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_product_image_rank_product_id\" ON \"image\" (rank, product_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "image_pkey",
|
"keyName": "image_pkey",
|
||||||
"columnNames": [
|
"columnNames": [
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { Migration } from "@mikro-orm/migrations"
|
||||||
|
|
||||||
|
export class Migration20250910154539 extends Migration {
|
||||||
|
override async up(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
`CREATE INDEX IF NOT EXISTS "IDX_image_product_id" ON "image" (product_id) WHERE deleted_at IS NULL;`
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
`CREATE INDEX IF NOT EXISTS "IDX_image_deleted_at" ON "image" (deleted_at) WHERE deleted_at IS NULL;`
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
`CREATE INDEX IF NOT EXISTS "IDX_product_image_url" ON "image" (url) WHERE deleted_at IS NULL;`
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
`CREATE INDEX IF NOT EXISTS "IDX_product_image_rank" ON "image" (rank) WHERE deleted_at IS NULL;`
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
`CREATE INDEX IF NOT EXISTS "IDX_product_image_url_rank_product_id" ON "image" (url, rank, product_id) WHERE deleted_at IS NULL;`
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
`CREATE INDEX IF NOT EXISTS "IDX_product_image_rank_product_id" ON "image" (rank, product_id) WHERE deleted_at IS NULL;`
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
override async down(): Promise<void> {
|
||||||
|
this.addSql(`drop index if exists "IDX_image_product_id";`)
|
||||||
|
this.addSql(`drop index if exists "IDX_image_deleted_at";`)
|
||||||
|
this.addSql(`drop index if exists "IDX_product_image_url";`)
|
||||||
|
this.addSql(`drop index if exists "IDX_product_image_rank";`)
|
||||||
|
this.addSql(`drop index if exists "IDX_product_image_url_rank_product_id";`)
|
||||||
|
this.addSql(
|
||||||
|
`alter table if exists "image" drop constraint if exists "image_pkey";`
|
||||||
|
)
|
||||||
|
this.addSql(`drop index if exists "IDX_product_image_rank_product_id";`)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,24 @@ const ProductImage = model
|
|||||||
unique: false,
|
unique: false,
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_product_image_rank",
|
||||||
|
on: ["rank"],
|
||||||
|
unique: false,
|
||||||
|
where: "deleted_at IS NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_product_image_url_rank_product_id",
|
||||||
|
on: ["url", "rank", "product_id"],
|
||||||
|
unique: false,
|
||||||
|
where: "deleted_at IS NULL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "IDX_product_image_rank_product_id",
|
||||||
|
on: ["rank", "product_id"],
|
||||||
|
unique: false,
|
||||||
|
where: "deleted_at IS NULL",
|
||||||
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
export default ProductImage
|
export default ProductImage
|
||||||
|
|||||||
Reference in New Issue
Block a user