chore(): Improve link indexes (#13459)
RESOLVE CORE-1183 **What** Update link indexes to include deleted_at index constraint
This commit is contained in:
committed by
GitHub
parent
0079464f32
commit
de9a21a9da
5
.changeset/eight-geckos-carry.md
Normal file
5
.changeset/eight-geckos-carry.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@medusajs/link-modules": patch
|
||||
---
|
||||
|
||||
chore(): Improve link indexes
|
||||
@@ -226,14 +226,14 @@ medusaIntegrationTestRunner({
|
||||
expect(regionResponse.data.region).toEqual(
|
||||
expect.objectContaining({
|
||||
id: regionResponse.data.region.id,
|
||||
payment_providers: [
|
||||
payment_providers: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
id: paymentProvider2Id,
|
||||
}),
|
||||
expect.objectContaining({
|
||||
id: paymentProviderId,
|
||||
}),
|
||||
],
|
||||
]),
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
@@ -73,9 +73,9 @@ moduleIntegrationTestRunner<ILinkModule>({
|
||||
"set names 'utf8';\n" +
|
||||
"\n" +
|
||||
'create table if not exists "user_user_car_car" ("user_id" varchar(255) not null, "car_id" varchar(255) not null, "id" varchar(255) not null, "created_at" timestamptz not null default CURRENT_TIMESTAMP, "updated_at" timestamptz not null default CURRENT_TIMESTAMP, "deleted_at" timestamptz null, constraint "user_user_car_car_pkey" primary key ("user_id", "car_id"));\n' +
|
||||
'create index if not exists "IDX_car_id_-92128f74" on "user_user_car_car" ("car_id");\n' +
|
||||
'create index if not exists "IDX_id_-92128f74" on "user_user_car_car" ("id");\n' +
|
||||
'create index if not exists "IDX_user_id_-92128f74" on "user_user_car_car" ("user_id");\n' +
|
||||
'CREATE INDEX IF NOT EXISTS "IDX_user_id_-92128f74" ON "user_user_car_car" ("user_id") WHERE deleted_at IS NULL;\n' +
|
||||
'CREATE INDEX IF NOT EXISTS "IDX_car_id_-92128f74" ON "user_user_car_car" ("car_id") WHERE deleted_at IS NULL;\n' +
|
||||
'create index if not exists "IDX_deleted_at_-92128f74" on "user_user_car_car" ("deleted_at");\n' +
|
||||
"\n",
|
||||
})
|
||||
@@ -94,9 +94,9 @@ moduleIntegrationTestRunner<ILinkModule>({
|
||||
"set names 'utf8';\n" +
|
||||
"\n" +
|
||||
'create table if not exists "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("user_id" varchar(255) not null, "very_long_table_name_of_custom_module_id" varchar(255) not null, "id" varchar(255) not null, "created_at" timestamptz not null default CURRENT_TIMESTAMP, "updated_at" timestamptz not null default CURRENT_TIMESTAMP, "deleted_at" timestamptz null, constraint "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de_pkey" primary key ("user_id", "very_long_table_name_of_custom_module_id"));\n' +
|
||||
'create index if not exists "IDX_very_long_table_name_of_custom_module_id_1776e67de" on "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("very_long_table_name_of_custom_module_id");\n' +
|
||||
'create index if not exists "IDX_id_1776e67de" on "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("id");\n' +
|
||||
'create index if not exists "IDX_user_id_1776e67de" on "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("user_id");\n' +
|
||||
'CREATE INDEX IF NOT EXISTS "IDX_user_id_1776e67de" ON "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("user_id") WHERE deleted_at IS NULL;\n' +
|
||||
'CREATE INDEX IF NOT EXISTS "IDX_very_long_table_name_of_custom_module_id_1776e67de" ON "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("very_long_table_name_of_custom_module_id") WHERE deleted_at IS NULL;\n' +
|
||||
'create index if not exists "IDX_deleted_at_1776e67de" on "user_user_cust_very_long_tabl_name_of_cust_modu1776e67de" ("deleted_at");\n' +
|
||||
"\n",
|
||||
})
|
||||
|
||||
@@ -90,7 +90,7 @@ export function generateEntity(
|
||||
type: "date",
|
||||
nullable: true,
|
||||
},
|
||||
},
|
||||
} as any,
|
||||
filters: {
|
||||
[SoftDeletableFilterKey]: mikroOrmSoftDeletableFilterOptions,
|
||||
},
|
||||
@@ -107,16 +107,38 @@ export function generateEntity(
|
||||
name: "IDX_id_" + hashTableName,
|
||||
},
|
||||
{
|
||||
properties: primary.foreignKey.split(","),
|
||||
properties: primary.foreignKey.split(",") as any,
|
||||
name:
|
||||
"IDX_" +
|
||||
primary.foreignKey.split(",").join("_") +
|
||||
"_" +
|
||||
hashTableName,
|
||||
expression:
|
||||
"CREATE INDEX IF NOT EXISTS " +
|
||||
'"IDX_' +
|
||||
primary.foreignKey.split(",").join("_") +
|
||||
"_" +
|
||||
hashTableName +
|
||||
'" ON "' +
|
||||
compressName(tableName) +
|
||||
'" ("' +
|
||||
primary.foreignKey.split(",").join(",") +
|
||||
'") WHERE deleted_at IS NULL',
|
||||
},
|
||||
{
|
||||
properties: foreign.foreignKey,
|
||||
properties: foreign.foreignKey as any,
|
||||
name: "IDX_" + foreign.foreignKey + "_" + hashTableName,
|
||||
expression:
|
||||
"CREATE INDEX IF NOT EXISTS " +
|
||||
'"IDX_' +
|
||||
foreign.foreignKey +
|
||||
"_" +
|
||||
hashTableName +
|
||||
'" ON "' +
|
||||
compressName(tableName) +
|
||||
'" ("' +
|
||||
foreign.foreignKey +
|
||||
'") WHERE deleted_at IS NULL',
|
||||
},
|
||||
{
|
||||
properties: ["deleted_at"],
|
||||
|
||||
@@ -526,7 +526,7 @@ moduleIntegrationTestRunner<IWorkflowEngineService>({
|
||||
throwOnError: false,
|
||||
})
|
||||
|
||||
await setTimeout(1000)
|
||||
await setTimeout(4000)
|
||||
|
||||
expect(step1InvokeMockAutoRetriesFalse).toHaveBeenCalledTimes(1)
|
||||
expect(step2InvokeMockAutoRetriesFalse).toHaveBeenCalledTimes(2)
|
||||
|
||||
Reference in New Issue
Block a user