fix(index): Apply various fixes to the index engine (#12501)

This commit is contained in:
Carlos R. L. Rodrigues
2025-05-19 15:14:25 -03:00
committed by GitHub
parent 32be40a2c0
commit 59bbff62d8
20 changed files with 194 additions and 133 deletions
@@ -1,6 +1,7 @@
import { IndexTypes } from "@medusajs/framework/types"
import { SqlEntityManager } from "@mikro-orm/postgresql"
import { schemaObjectRepresentationPropertiesToOmit } from "@types"
import { getPivotTableName, normalizeTableName } from "./normalze-table-name"
export async function createPartitions(
schemaObjectRepresentation: IndexTypes.SchemaObjectRepresentation,
@@ -18,7 +19,7 @@ export async function createPartitions(
schemaObjectRepresentation[key].listeners.length > 0
)
.map((key) => {
const cName = key.toLowerCase()
const cName = normalizeTableName(key)
if (createdPartitions.has(cName)) {
return []
@@ -35,7 +36,8 @@ export async function createPartitions(
continue
}
const pName = `cat_pivot_${parent.ref.entity}${key}`.toLowerCase()
const pName = getPivotTableName(`${parent.ref.entity}${key}`)
if (createdPartitions.has(pName)) {
continue
}
@@ -63,7 +65,7 @@ export async function createPartitions(
schemaObjectRepresentation[key].listeners.length > 0
)
.map((key) => {
const cName = key.toLowerCase()
const cName = normalizeTableName(key)
const part: string[] = []
part.push(
@@ -79,7 +81,8 @@ export async function createPartitions(
continue
}
const pName = `cat_pivot_${parent.ref.entity}${key}`.toLowerCase()
const pName = getPivotTableName(`${parent.ref.entity}${key}`)
part.push(
`CREATE INDEX CONCURRENTLY IF NOT EXISTS "IDX_${pName}_child_id" ON ${activeSchema}${pName} ("child_id")`
)