fix: Unique constraint should account for soft deleted records (#11048)
FIXES FRMW-2878 **What** Currently, the `one-to-one` unique constraints does not account for deleted record. This prevents from inserting a new record wth the same fk if another one is deleted. **Caveat** `hasOne` with FK option is meant to be a special case, for example a many to one - one to many without defining the other side of the relation. In that case we don't handle this behaviour and keep it as it is
This commit is contained in:
1 parent
ecc8efcb04
commit
da3906efa4
22 files changed
+361
-217
No files matched your search
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/cart": patch
|
||||||
|
"@medusajs/fulfillment": patch
|
||||||
|
"@medusajs/notification": patch
|
||||||
|
"@medusajs/payment": patch
|
||||||
|
"@medusajs/promotion": patch
|
||||||
|
"@medusajs/region": patch
|
||||||
|
"@medusajs/stock-location": patch
|
||||||
|
"@medusajs/workflow-engine-inmemory": patch
|
||||||
|
"@medusajs/workflow-engine-redis": patch
|
||||||
|
"@medusajs/utils": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: Unique constraint should account for soft deleted records
|
||||||
@@ -3094,6 +3094,7 @@ describe("Entity builder", () => {
|
|||||||
owner: true,
|
owner: true,
|
||||||
kind: "1:1",
|
kind: "1:1",
|
||||||
cascade: ["persist", "soft-remove"],
|
cascade: ["persist", "soft-remove"],
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
user_id: {
|
user_id: {
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
@@ -3208,6 +3209,7 @@ describe("Entity builder", () => {
|
|||||||
name: "email",
|
name: "email",
|
||||||
entity: "Email",
|
entity: "Email",
|
||||||
fieldName: "email_id",
|
fieldName: "email_id",
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
email_id: {
|
email_id: {
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
@@ -3320,6 +3322,7 @@ describe("Entity builder", () => {
|
|||||||
entity: "Email",
|
entity: "Email",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
fieldName: "emails_id",
|
fieldName: "emails_id",
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
emails_id: {
|
emails_id: {
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
@@ -3423,6 +3426,7 @@ describe("Entity builder", () => {
|
|||||||
entity: "Email",
|
entity: "Email",
|
||||||
mappedBy: "owner",
|
mappedBy: "owner",
|
||||||
fieldName: "email_id",
|
fieldName: "email_id",
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
email_id: {
|
email_id: {
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
@@ -3530,6 +3534,7 @@ describe("Entity builder", () => {
|
|||||||
cascade: ["persist", "soft-remove"],
|
cascade: ["persist", "soft-remove"],
|
||||||
mappedBy: "user",
|
mappedBy: "user",
|
||||||
fieldName: "email_id",
|
fieldName: "email_id",
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
email_id: {
|
email_id: {
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
@@ -3707,6 +3712,7 @@ describe("Entity builder", () => {
|
|||||||
cascade: ["persist", "soft-remove"],
|
cascade: ["persist", "soft-remove"],
|
||||||
mappedBy: "user",
|
mappedBy: "user",
|
||||||
fieldName: "email_id",
|
fieldName: "email_id",
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
email_id: {
|
email_id: {
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
@@ -3791,6 +3797,7 @@ describe("Entity builder", () => {
|
|||||||
kind: "1:1",
|
kind: "1:1",
|
||||||
cascade: ["persist", "soft-remove"],
|
cascade: ["persist", "soft-remove"],
|
||||||
fieldName: "user_id",
|
fieldName: "user_id",
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
user_id: {
|
user_id: {
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
@@ -4125,8 +4132,8 @@ describe("Entity builder", () => {
|
|||||||
expect(settingMetadata.indexes).toEqual([
|
expect(settingMetadata.indexes).toEqual([
|
||||||
{
|
{
|
||||||
expression:
|
expression:
|
||||||
'CREATE INDEX IF NOT EXISTS "IDX_setting_user_id" ON "setting" (user_id) WHERE deleted_at IS NULL',
|
'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_setting_user_id_unique" ON "setting" (user_id) WHERE deleted_at IS NULL',
|
||||||
name: "IDX_setting_user_id",
|
name: "IDX_setting_user_id_unique",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
expression:
|
expression:
|
||||||
@@ -4739,6 +4746,7 @@ describe("Entity builder", () => {
|
|||||||
mappedBy: "email",
|
mappedBy: "email",
|
||||||
onDelete: undefined,
|
onDelete: undefined,
|
||||||
owner: true,
|
owner: true,
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
user_id: {
|
user_id: {
|
||||||
kind: "scalar",
|
kind: "scalar",
|
||||||
@@ -4953,6 +4961,7 @@ describe("Entity builder", () => {
|
|||||||
onDelete: undefined,
|
onDelete: undefined,
|
||||||
mappedBy: "email",
|
mappedBy: "email",
|
||||||
owner: true,
|
owner: true,
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
user_id: {
|
user_id: {
|
||||||
kind: "scalar",
|
kind: "scalar",
|
||||||
@@ -5572,6 +5581,7 @@ describe("Entity builder", () => {
|
|||||||
mappedBy: "email",
|
mappedBy: "email",
|
||||||
onDelete: undefined,
|
onDelete: undefined,
|
||||||
owner: true,
|
owner: true,
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
user_id: {
|
user_id: {
|
||||||
kind: "scalar",
|
kind: "scalar",
|
||||||
@@ -5772,6 +5782,7 @@ describe("Entity builder", () => {
|
|||||||
mappedBy: "email",
|
mappedBy: "email",
|
||||||
onDelete: undefined,
|
onDelete: undefined,
|
||||||
owner: true,
|
owner: true,
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
user_id: {
|
user_id: {
|
||||||
kind: "scalar",
|
kind: "scalar",
|
||||||
@@ -5995,6 +6006,7 @@ describe("Entity builder", () => {
|
|||||||
nullable: false,
|
nullable: false,
|
||||||
onDelete: undefined,
|
onDelete: undefined,
|
||||||
owner: true,
|
owner: true,
|
||||||
|
unique: false,
|
||||||
},
|
},
|
||||||
parent_id: {
|
parent_id: {
|
||||||
name: "parent_id",
|
name: "parent_id",
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ export function defineHasOneRelationship(
|
|||||||
*/
|
*/
|
||||||
export function defineHasOneWithFKRelationship(
|
export function defineHasOneWithFKRelationship(
|
||||||
MikroORMEntity: EntityConstructor<any>,
|
MikroORMEntity: EntityConstructor<any>,
|
||||||
|
entity: DmlEntity<any, any>,
|
||||||
relationship: RelationshipMetadata,
|
relationship: RelationshipMetadata,
|
||||||
{ relatedModelName }: { relatedModelName: string },
|
{ relatedModelName }: { relatedModelName: string },
|
||||||
cascades: EntityCascades<string[], string[]>
|
cascades: EntityCascades<string[], string[]>
|
||||||
@@ -198,6 +199,7 @@ export function defineHasOneWithFKRelationship(
|
|||||||
fieldName: foreignKeyName,
|
fieldName: foreignKeyName,
|
||||||
...(relationship.nullable ? { nullable: relationship.nullable } : {}),
|
...(relationship.nullable ? { nullable: relationship.nullable } : {}),
|
||||||
...(mappedBy ? { mappedBy } : {}),
|
...(mappedBy ? { mappedBy } : {}),
|
||||||
|
unique: false,
|
||||||
//orphanRemoval: true,
|
//orphanRemoval: true,
|
||||||
} as OneToOneOptions<any, any>
|
} as OneToOneOptions<any, any>
|
||||||
|
|
||||||
@@ -508,6 +510,10 @@ export function defineBelongsToRelationship(
|
|||||||
mappedBy: mappedBy,
|
mappedBy: mappedBy,
|
||||||
fieldName: foreignKeyName,
|
fieldName: foreignKeyName,
|
||||||
owner: true,
|
owner: true,
|
||||||
|
/**
|
||||||
|
* If we decide to support non soft deletable then this should be true and the unique index id should be removed
|
||||||
|
*/
|
||||||
|
unique: false,
|
||||||
// orphanRemoval: true,
|
// orphanRemoval: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,6 +529,7 @@ export function defineBelongsToRelationship(
|
|||||||
{
|
{
|
||||||
on: [foreignKeyName],
|
on: [foreignKeyName],
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
|
unique: true,
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -821,6 +828,7 @@ export function defineRelationship(
|
|||||||
case "hasOneWithFK":
|
case "hasOneWithFK":
|
||||||
defineHasOneWithFKRelationship(
|
defineHasOneWithFKRelationship(
|
||||||
MikroORMEntity,
|
MikroORMEntity,
|
||||||
|
entity,
|
||||||
relationship,
|
relationship,
|
||||||
relatedEntityInfo,
|
relatedEntityInfo,
|
||||||
cascades
|
cascades
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ export function defineMikroOrmCliConfig(
|
|||||||
user: "postgres",
|
user: "postgres",
|
||||||
password: "",
|
password: "",
|
||||||
...(options as any),
|
...(options as any),
|
||||||
entities,
|
entities: entities.filter(Boolean),
|
||||||
migrations: {
|
migrations: {
|
||||||
generator: CustomTsMigrationGenerator,
|
generator: CustomTsMigrationGenerator,
|
||||||
...options.migrations,
|
...options.migrations,
|
||||||
|
|||||||
@@ -309,24 +309,6 @@
|
|||||||
"name": "cart",
|
"name": "cart",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
|
||||||
"columnNames": [
|
|
||||||
"shipping_address_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
|
||||||
"keyName": "cart_shipping_address_id_unique",
|
|
||||||
"primary": false,
|
|
||||||
"unique": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"columnNames": [
|
|
||||||
"billing_address_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
|
||||||
"keyName": "cart_billing_address_id_unique",
|
|
||||||
"primary": false,
|
|
||||||
"unique": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"keyName": "IDX_cart_deleted_at",
|
"keyName": "IDX_cart_deleted_at",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { Migration } from "@mikro-orm/migrations"
|
||||||
|
|
||||||
|
export class Migration20250120115059 extends Migration {
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart" drop constraint if exists "cart_shipping_address_id_unique";'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart" drop constraint if exists "cart_billing_address_id_unique";'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart" add constraint "cart_shipping_address_id_unique" unique ("shipping_address_id");'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "cart" add constraint "cart_billing_address_id_unique" unique ("billing_address_id");'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
{
|
{
|
||||||
"namespaces": [
|
"namespaces": ["public"],
|
||||||
"public"
|
|
||||||
],
|
|
||||||
"name": "public",
|
"name": "public",
|
||||||
"tables": [
|
"tables": [
|
||||||
{
|
{
|
||||||
@@ -161,9 +159,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "fulfillment_address_pkey",
|
"keyName": "fulfillment_address_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -242,9 +238,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "fulfillment_provider_pkey",
|
"keyName": "fulfillment_provider_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -349,9 +343,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "fulfillment_set_pkey",
|
"keyName": "fulfillment_set_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -465,9 +457,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "service_zone_pkey",
|
"keyName": "service_zone_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -478,13 +468,9 @@
|
|||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"service_zone_fulfillment_set_id_foreign": {
|
"service_zone_fulfillment_set_id_foreign": {
|
||||||
"constraintName": "service_zone_fulfillment_set_id_foreign",
|
"constraintName": "service_zone_fulfillment_set_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["fulfillment_set_id"],
|
||||||
"fulfillment_set_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.service_zone",
|
"localTableName": "public.service_zone",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.fulfillment_set",
|
"referencedTableName": "public.fulfillment_set",
|
||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
@@ -511,12 +497,7 @@
|
|||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"default": "'country'",
|
"default": "'country'",
|
||||||
"enumItems": [
|
"enumItems": ["country", "province", "city", "zip"],
|
||||||
"country",
|
|
||||||
"province",
|
|
||||||
"city",
|
|
||||||
"zip"
|
|
||||||
],
|
|
||||||
"mappedType": "enum"
|
"mappedType": "enum"
|
||||||
},
|
},
|
||||||
"country_code": {
|
"country_code": {
|
||||||
@@ -656,9 +637,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "geo_zone_pkey",
|
"keyName": "geo_zone_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -669,13 +648,9 @@
|
|||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"geo_zone_service_zone_id_foreign": {
|
"geo_zone_service_zone_id_foreign": {
|
||||||
"constraintName": "geo_zone_service_zone_id_foreign",
|
"constraintName": "geo_zone_service_zone_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["service_zone_id"],
|
||||||
"service_zone_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.geo_zone",
|
"localTableName": "public.geo_zone",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.service_zone",
|
"referencedTableName": "public.service_zone",
|
||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
@@ -768,9 +743,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "shipping_option_type_pkey",
|
"keyName": "shipping_option_type_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -875,9 +848,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "shipping_profile_pkey",
|
"keyName": "shipping_profile_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -916,10 +887,7 @@
|
|||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"default": "'flat'",
|
"default": "'flat'",
|
||||||
"enumItems": [
|
"enumItems": ["calculated", "flat"],
|
||||||
"calculated",
|
|
||||||
"flat"
|
|
||||||
],
|
|
||||||
"mappedType": "enum"
|
"mappedType": "enum"
|
||||||
},
|
},
|
||||||
"data": {
|
"data": {
|
||||||
@@ -1013,9 +981,7 @@
|
|||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
{
|
||||||
"columnNames": [
|
"columnNames": ["shipping_option_type_id"],
|
||||||
"shipping_option_type_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"keyName": "shipping_option_shipping_option_type_id_unique",
|
"keyName": "shipping_option_shipping_option_type_id_unique",
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
@@ -1060,9 +1026,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "shipping_option_pkey",
|
"keyName": "shipping_option_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -1073,52 +1037,36 @@
|
|||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"shipping_option_service_zone_id_foreign": {
|
"shipping_option_service_zone_id_foreign": {
|
||||||
"constraintName": "shipping_option_service_zone_id_foreign",
|
"constraintName": "shipping_option_service_zone_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["service_zone_id"],
|
||||||
"service_zone_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.shipping_option",
|
"localTableName": "public.shipping_option",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.service_zone",
|
"referencedTableName": "public.service_zone",
|
||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
},
|
},
|
||||||
"shipping_option_shipping_profile_id_foreign": {
|
"shipping_option_shipping_profile_id_foreign": {
|
||||||
"constraintName": "shipping_option_shipping_profile_id_foreign",
|
"constraintName": "shipping_option_shipping_profile_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["shipping_profile_id"],
|
||||||
"shipping_profile_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.shipping_option",
|
"localTableName": "public.shipping_option",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.shipping_profile",
|
"referencedTableName": "public.shipping_profile",
|
||||||
"deleteRule": "set null",
|
"deleteRule": "set null",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
},
|
},
|
||||||
"shipping_option_provider_id_foreign": {
|
"shipping_option_provider_id_foreign": {
|
||||||
"constraintName": "shipping_option_provider_id_foreign",
|
"constraintName": "shipping_option_provider_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["provider_id"],
|
||||||
"provider_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.shipping_option",
|
"localTableName": "public.shipping_option",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.fulfillment_provider",
|
"referencedTableName": "public.fulfillment_provider",
|
||||||
"deleteRule": "set null",
|
"deleteRule": "set null",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
},
|
},
|
||||||
"shipping_option_shipping_option_type_id_foreign": {
|
"shipping_option_shipping_option_type_id_foreign": {
|
||||||
"constraintName": "shipping_option_shipping_option_type_id_foreign",
|
"constraintName": "shipping_option_shipping_option_type_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["shipping_option_type_id"],
|
||||||
"shipping_option_type_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.shipping_option",
|
"localTableName": "public.shipping_option",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.shipping_option_type",
|
"referencedTableName": "public.shipping_option_type",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
}
|
}
|
||||||
@@ -1152,16 +1100,7 @@
|
|||||||
"autoincrement": false,
|
"autoincrement": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"enumItems": [
|
"enumItems": ["in", "eq", "ne", "gt", "gte", "lt", "lte", "nin"],
|
||||||
"in",
|
|
||||||
"eq",
|
|
||||||
"ne",
|
|
||||||
"gt",
|
|
||||||
"gte",
|
|
||||||
"lt",
|
|
||||||
"lte",
|
|
||||||
"nin"
|
|
||||||
],
|
|
||||||
"mappedType": "enum"
|
"mappedType": "enum"
|
||||||
},
|
},
|
||||||
"value": {
|
"value": {
|
||||||
@@ -1238,9 +1177,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "shipping_option_rule_pkey",
|
"keyName": "shipping_option_rule_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -1251,13 +1188,9 @@
|
|||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"shipping_option_rule_shipping_option_id_foreign": {
|
"shipping_option_rule_shipping_option_id_foreign": {
|
||||||
"constraintName": "shipping_option_rule_shipping_option_id_foreign",
|
"constraintName": "shipping_option_rule_shipping_option_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["shipping_option_id"],
|
||||||
"shipping_option_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.shipping_option_rule",
|
"localTableName": "public.shipping_option_rule",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.shipping_option",
|
"referencedTableName": "public.shipping_option",
|
||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
@@ -1435,9 +1368,7 @@
|
|||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
{
|
||||||
"columnNames": [
|
"columnNames": ["provider_id"],
|
||||||
"provider_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"keyName": "fulfillment_provider_id_unique",
|
"keyName": "fulfillment_provider_id_unique",
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
@@ -1445,9 +1376,7 @@
|
|||||||
"unique": true
|
"unique": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"columnNames": [
|
"columnNames": ["delivery_address_id"],
|
||||||
"delivery_address_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"keyName": "fulfillment_delivery_address_id_unique",
|
"keyName": "fulfillment_delivery_address_id_unique",
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
@@ -1483,9 +1412,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "fulfillment_pkey",
|
"keyName": "fulfillment_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -1496,39 +1423,27 @@
|
|||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"fulfillment_provider_id_foreign": {
|
"fulfillment_provider_id_foreign": {
|
||||||
"constraintName": "fulfillment_provider_id_foreign",
|
"constraintName": "fulfillment_provider_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["provider_id"],
|
||||||
"provider_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.fulfillment",
|
"localTableName": "public.fulfillment",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.fulfillment_provider",
|
"referencedTableName": "public.fulfillment_provider",
|
||||||
"deleteRule": "set null",
|
"deleteRule": "set null",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
},
|
},
|
||||||
"fulfillment_shipping_option_id_foreign": {
|
"fulfillment_shipping_option_id_foreign": {
|
||||||
"constraintName": "fulfillment_shipping_option_id_foreign",
|
"constraintName": "fulfillment_shipping_option_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["shipping_option_id"],
|
||||||
"shipping_option_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.fulfillment",
|
"localTableName": "public.fulfillment",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.shipping_option",
|
"referencedTableName": "public.shipping_option",
|
||||||
"deleteRule": "set null",
|
"deleteRule": "set null",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
},
|
},
|
||||||
"fulfillment_delivery_address_id_foreign": {
|
"fulfillment_delivery_address_id_foreign": {
|
||||||
"constraintName": "fulfillment_delivery_address_id_foreign",
|
"constraintName": "fulfillment_delivery_address_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["delivery_address_id"],
|
||||||
"delivery_address_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.fulfillment",
|
"localTableName": "public.fulfillment",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.fulfillment_address",
|
"referencedTableName": "public.fulfillment_address",
|
||||||
"deleteRule": "set null",
|
"deleteRule": "set null",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
@@ -1639,9 +1554,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "fulfillment_label_pkey",
|
"keyName": "fulfillment_label_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -1652,13 +1565,9 @@
|
|||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"fulfillment_label_fulfillment_id_foreign": {
|
"fulfillment_label_fulfillment_id_foreign": {
|
||||||
"constraintName": "fulfillment_label_fulfillment_id_foreign",
|
"constraintName": "fulfillment_label_fulfillment_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["fulfillment_id"],
|
||||||
"fulfillment_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.fulfillment_label",
|
"localTableName": "public.fulfillment_label",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.fulfillment",
|
"referencedTableName": "public.fulfillment",
|
||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
@@ -1823,9 +1732,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "fulfillment_item_pkey",
|
"keyName": "fulfillment_item_pkey",
|
||||||
"columnNames": [
|
"columnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"constraint": true,
|
"constraint": true,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
@@ -1836,13 +1743,9 @@
|
|||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"fulfillment_item_fulfillment_id_foreign": {
|
"fulfillment_item_fulfillment_id_foreign": {
|
||||||
"constraintName": "fulfillment_item_fulfillment_id_foreign",
|
"constraintName": "fulfillment_item_fulfillment_id_foreign",
|
||||||
"columnNames": [
|
"columnNames": ["fulfillment_id"],
|
||||||
"fulfillment_id"
|
|
||||||
],
|
|
||||||
"localTableName": "public.fulfillment_item",
|
"localTableName": "public.fulfillment_item",
|
||||||
"referencedColumnNames": [
|
"referencedColumnNames": ["id"],
|
||||||
"id"
|
|
||||||
],
|
|
||||||
"referencedTableName": "public.fulfillment",
|
"referencedTableName": "public.fulfillment",
|
||||||
"deleteRule": "cascade",
|
"deleteRule": "cascade",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
import { Migration } from "@mikro-orm/migrations"
|
||||||
|
|
||||||
|
export class Migration20250120115002 extends Migration {
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "shipping_option" add constraint "shipping_option_provider_id_foreign" foreign key ("provider_id") references "fulfillment_provider" ("id") on update cascade on delete set null;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "shipping_option" add constraint "shipping_option_shipping_option_type_id_foreign" foreign key ("shipping_option_type_id") references "shipping_option_type" ("id") on update cascade;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'CREATE INDEX IF NOT EXISTS "IDX_shipping_option_provider_id" ON "shipping_option" (provider_id) WHERE deleted_at IS NULL;'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "fulfillment" add constraint "fulfillment_provider_id_foreign" foreign key ("provider_id") references "fulfillment_provider" ("id") on update cascade on delete set null;'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "fulfillment" add constraint "fulfillment_delivery_address_id_foreign" foreign key ("delivery_address_id") references "fulfillment_address" ("id") on update cascade on delete set null;'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "shipping_option" drop constraint if exists "shipping_option_provider_id_foreign";'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "shipping_option" drop constraint if exists "shipping_option_shipping_option_type_id_foreign";'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "fulfillment" drop constraint if exists "fulfillment_provider_id_foreign";'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "fulfillment" drop constraint if exists "fulfillment_delivery_address_id_foreign";'
|
||||||
|
)
|
||||||
|
|
||||||
|
this.addSql('drop index if exists "IDX_shipping_option_provider_id";')
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"namespaces": ["public"],
|
"namespaces": [
|
||||||
|
"public"
|
||||||
|
],
|
||||||
"name": "public",
|
"name": "public",
|
||||||
"tables": [
|
"tables": [
|
||||||
{
|
{
|
||||||
@@ -87,9 +89,19 @@
|
|||||||
"name": "notification_provider",
|
"name": "notification_provider",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
|
{
|
||||||
|
"keyName": "IDX_notification_provider_deleted_at",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_deleted_at\" ON \"notification_provider\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "notification_provider_pkey",
|
"keyName": "notification_provider_pkey",
|
||||||
"columnNames": ["id"],
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
@@ -216,7 +228,11 @@
|
|||||||
"primary": false,
|
"primary": false,
|
||||||
"nullable": false,
|
"nullable": false,
|
||||||
"default": "'pending'",
|
"default": "'pending'",
|
||||||
"enumItems": ["pending", "success", "failure"],
|
"enumItems": [
|
||||||
|
"pending",
|
||||||
|
"success",
|
||||||
|
"failure"
|
||||||
|
],
|
||||||
"mappedType": "enum"
|
"mappedType": "enum"
|
||||||
},
|
},
|
||||||
"provider_id": {
|
"provider_id": {
|
||||||
@@ -288,9 +304,19 @@
|
|||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_id\" ON \"notification\" (provider_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_provider_id\" ON \"notification\" (provider_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_notification_deleted_at",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_notification_deleted_at\" ON \"notification\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "notification_pkey",
|
"keyName": "notification_pkey",
|
||||||
"columnNames": ["id"],
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
@@ -300,9 +326,13 @@
|
|||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"notification_provider_id_foreign": {
|
"notification_provider_id_foreign": {
|
||||||
"constraintName": "notification_provider_id_foreign",
|
"constraintName": "notification_provider_id_foreign",
|
||||||
"columnNames": ["provider_id"],
|
"columnNames": [
|
||||||
|
"provider_id"
|
||||||
|
],
|
||||||
"localTableName": "public.notification",
|
"localTableName": "public.notification",
|
||||||
"referencedColumnNames": ["id"],
|
"referencedColumnNames": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
"referencedTableName": "public.notification_provider",
|
"referencedTableName": "public.notification_provider",
|
||||||
"deleteRule": "set null",
|
"deleteRule": "set null",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
|
export class Migration20250120110514 extends Migration {
|
||||||
|
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_notification_provider_deleted_at" ON "notification_provider" (deleted_at) WHERE deleted_at IS NULL;');
|
||||||
|
|
||||||
|
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_notification_deleted_at" ON "notification" (deleted_at) WHERE deleted_at IS NULL;');
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql('drop index if exists "IDX_notification_provider_deleted_at";');
|
||||||
|
|
||||||
|
this.addSql('drop index if exists "IDX_notification_deleted_at";');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -784,15 +784,6 @@
|
|||||||
"name": "payment",
|
"name": "payment",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
|
||||||
"columnNames": [
|
|
||||||
"payment_session_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
|
||||||
"keyName": "payment_payment_session_id_unique",
|
|
||||||
"primary": false,
|
|
||||||
"unique": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"keyName": "IDX_payment_payment_collection_id",
|
"keyName": "IDX_payment_payment_collection_id",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
@@ -802,12 +793,12 @@
|
|||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_payment_payment_collection_id\" ON \"payment\" (payment_collection_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_payment_payment_collection_id\" ON \"payment\" (payment_collection_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_payment_payment_session_id",
|
"keyName": "IDX_payment_payment_session_id_unique",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_payment_payment_session_id\" ON \"payment\" (payment_session_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_payment_payment_session_id_unique\" ON \"payment\" (payment_session_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_payment_deleted_at",
|
"keyName": "IDX_payment_deleted_at",
|
||||||
@@ -825,6 +816,14 @@
|
|||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_payment_provider_id\" ON \"payment\" (provider_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_payment_provider_id\" ON \"payment\" (provider_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_payment_payment_session_id",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_payment_payment_session_id\" ON \"payment\" (payment_session_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "payment_pkey",
|
"keyName": "payment_pkey",
|
||||||
"columnNames": [
|
"columnNames": [
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { Migration } from "@mikro-orm/migrations"
|
||||||
|
|
||||||
|
export class Migration20250120110552 extends Migration {
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "payment" drop constraint if exists "payment_payment_session_id_unique";'
|
||||||
|
)
|
||||||
|
this.addSql(
|
||||||
|
'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_payment_payment_session_id_unique" ON "payment" (payment_session_id) WHERE deleted_at IS NULL;'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql('drop index if exists "IDX_payment_payment_session_id_unique";')
|
||||||
|
this.addSql(
|
||||||
|
'alter table if exists "payment" add constraint "payment_payment_session_id_unique" unique ("payment_session_id");'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -242,15 +242,6 @@
|
|||||||
"name": "promotion_campaign_budget",
|
"name": "promotion_campaign_budget",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
|
||||||
"columnNames": [
|
|
||||||
"campaign_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
|
||||||
"keyName": "promotion_campaign_budget_campaign_id_unique",
|
|
||||||
"primary": false,
|
|
||||||
"unique": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"keyName": "IDX_campaign_budget_type",
|
"keyName": "IDX_campaign_budget_type",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
@@ -260,12 +251,12 @@
|
|||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_campaign_budget_type\" ON \"promotion_campaign_budget\" (type) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_campaign_budget_type\" ON \"promotion_campaign_budget\" (type) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_promotion_campaign_budget_campaign_id",
|
"keyName": "IDX_promotion_campaign_budget_campaign_id_unique",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_promotion_campaign_budget_campaign_id\" ON \"promotion_campaign_budget\" (campaign_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_promotion_campaign_budget_campaign_id_unique\" ON \"promotion_campaign_budget\" (campaign_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_promotion_campaign_budget_deleted_at",
|
"keyName": "IDX_promotion_campaign_budget_deleted_at",
|
||||||
@@ -630,15 +621,6 @@
|
|||||||
"name": "promotion_application_method",
|
"name": "promotion_application_method",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
|
||||||
"columnNames": [
|
|
||||||
"promotion_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
|
||||||
"keyName": "promotion_application_method_promotion_id_unique",
|
|
||||||
"primary": false,
|
|
||||||
"unique": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"keyName": "IDX_application_method_type",
|
"keyName": "IDX_application_method_type",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
@@ -664,12 +646,12 @@
|
|||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_application_method_allocation\" ON \"promotion_application_method\" (allocation) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_application_method_allocation\" ON \"promotion_application_method\" (allocation) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_promotion_application_method_promotion_id",
|
"keyName": "IDX_promotion_application_method_promotion_id_unique",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_promotion_application_method_promotion_id\" ON \"promotion_application_method\" (promotion_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_promotion_application_method_promotion_id_unique\" ON \"promotion_application_method\" (promotion_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_promotion_application_method_deleted_at",
|
"keyName": "IDX_promotion_application_method_deleted_at",
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
|
export class Migration20250120110700 extends Migration {
|
||||||
|
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql('alter table if exists "promotion_campaign_budget" drop constraint if exists "promotion_campaign_budget_campaign_id_unique";');
|
||||||
|
this.addSql('drop index if exists "IDX_promotion_campaign_budget_campaign_id";');
|
||||||
|
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_promotion_campaign_budget_campaign_id_unique" ON "promotion_campaign_budget" (campaign_id) WHERE deleted_at IS NULL;');
|
||||||
|
|
||||||
|
this.addSql('alter table if exists "promotion_application_method" drop constraint if exists "promotion_application_method_promotion_id_unique";');
|
||||||
|
this.addSql('drop index if exists "IDX_promotion_application_method_promotion_id";');
|
||||||
|
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_promotion_application_method_promotion_id_unique" ON "promotion_application_method" (promotion_id) WHERE deleted_at IS NULL;');
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql('drop index if exists "IDX_promotion_campaign_budget_campaign_id_unique";');
|
||||||
|
this.addSql('alter table if exists "promotion_campaign_budget" add constraint "promotion_campaign_budget_campaign_id_unique" unique ("campaign_id");');
|
||||||
|
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_promotion_campaign_budget_campaign_id" ON "promotion_campaign_budget" (campaign_id) WHERE deleted_at IS NULL;');
|
||||||
|
|
||||||
|
this.addSql('drop index if exists "IDX_promotion_application_method_promotion_id_unique";');
|
||||||
|
this.addSql('alter table if exists "promotion_application_method" add constraint "promotion_application_method_promotion_id_unique" unique ("promotion_id");');
|
||||||
|
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_promotion_application_method_promotion_id" ON "promotion_application_method" (promotion_id) WHERE deleted_at IS NULL;');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"namespaces": ["public"],
|
"namespaces": [
|
||||||
|
"public"
|
||||||
|
],
|
||||||
"name": "public",
|
"name": "public",
|
||||||
"tables": [
|
"tables": [
|
||||||
{
|
{
|
||||||
@@ -86,9 +88,19 @@
|
|||||||
"name": "region",
|
"name": "region",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
|
{
|
||||||
|
"keyName": "IDX_region_deleted_at",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_region_deleted_at\" ON \"region\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "region_pkey",
|
"keyName": "region_pkey",
|
||||||
"columnNames": ["id"],
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
@@ -198,17 +210,35 @@
|
|||||||
"name": "region_country",
|
"name": "region_country",
|
||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
|
{
|
||||||
|
"keyName": "IDX_region_country_region_id",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_region_country_region_id\" ON \"region_country\" (region_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_region_country_deleted_at",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_region_country_deleted_at\" ON \"region_country\" (deleted_at) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_region_country_region_id_iso_2_unique",
|
"keyName": "IDX_region_country_region_id_iso_2_unique",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_region_country_region_id_iso_2_unique\" ON \"region_country\" (region_id, iso_2)"
|
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_region_country_region_id_iso_2_unique\" ON \"region_country\" (region_id, iso_2) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "region_country_pkey",
|
"keyName": "region_country_pkey",
|
||||||
"columnNames": ["iso_2"],
|
"columnNames": [
|
||||||
|
"iso_2"
|
||||||
|
],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": true,
|
"primary": true,
|
||||||
"unique": true
|
"unique": true
|
||||||
@@ -218,9 +248,13 @@
|
|||||||
"foreignKeys": {
|
"foreignKeys": {
|
||||||
"region_country_region_id_foreign": {
|
"region_country_region_id_foreign": {
|
||||||
"constraintName": "region_country_region_id_foreign",
|
"constraintName": "region_country_region_id_foreign",
|
||||||
"columnNames": ["region_id"],
|
"columnNames": [
|
||||||
|
"region_id"
|
||||||
|
],
|
||||||
"localTableName": "public.region_country",
|
"localTableName": "public.region_country",
|
||||||
"referencedColumnNames": ["id"],
|
"referencedColumnNames": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
"referencedTableName": "public.region",
|
"referencedTableName": "public.region",
|
||||||
"deleteRule": "set null",
|
"deleteRule": "set null",
|
||||||
"updateRule": "cascade"
|
"updateRule": "cascade"
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
|
export class Migration20250120110744 extends Migration {
|
||||||
|
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_region_deleted_at" ON "region" (deleted_at) WHERE deleted_at IS NULL;');
|
||||||
|
|
||||||
|
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_region_country_region_id" ON "region_country" (region_id) WHERE deleted_at IS NULL;');
|
||||||
|
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_region_country_deleted_at" ON "region_country" (deleted_at) WHERE deleted_at IS NULL;');
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql('drop index if exists "IDX_region_deleted_at";');
|
||||||
|
|
||||||
|
this.addSql('drop index if exists "IDX_region_country_region_id";');
|
||||||
|
this.addSql('drop index if exists "IDX_region_country_deleted_at";');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+2
-11
@@ -228,21 +228,12 @@
|
|||||||
"schema": "public",
|
"schema": "public",
|
||||||
"indexes": [
|
"indexes": [
|
||||||
{
|
{
|
||||||
"columnNames": [
|
"keyName": "IDX_stock_location_address_id_unique",
|
||||||
"address_id"
|
|
||||||
],
|
|
||||||
"composite": false,
|
|
||||||
"keyName": "stock_location_address_id_unique",
|
|
||||||
"primary": false,
|
|
||||||
"unique": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"keyName": "IDX_stock_location_address_id",
|
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
"composite": false,
|
"composite": false,
|
||||||
"primary": false,
|
"primary": false,
|
||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_stock_location_address_id\" ON \"stock_location\" (address_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_stock_location_address_id_unique\" ON \"stock_location\" (address_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_stock_location_deleted_at",
|
"keyName": "IDX_stock_location_deleted_at",
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
|
export class Migration20250120110820 extends Migration {
|
||||||
|
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql('alter table if exists "stock_location" drop constraint if exists "stock_location_address_id_unique";');
|
||||||
|
this.addSql('drop index if exists "IDX_stock_location_address_id";');
|
||||||
|
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_stock_location_address_id_unique" ON "stock_location" (address_id) WHERE deleted_at IS NULL;');
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql('drop index if exists "IDX_stock_location_address_id_unique";');
|
||||||
|
this.addSql('alter table if exists "stock_location" add constraint "stock_location_address_id_unique" unique ("address_id");');
|
||||||
|
this.addSql('CREATE INDEX IF NOT EXISTS "IDX_stock_location_address_id" ON "stock_location" (address_id) WHERE deleted_at IS NULL;');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -23,6 +23,11 @@ export const WorkflowExecution = model
|
|||||||
on: ["transaction_id"],
|
on: ["transaction_id"],
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
on: ["workflow_id", "transaction_id"],
|
||||||
|
unique: true,
|
||||||
|
where: "deleted_at IS NULL",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
on: ["state"],
|
on: ["state"],
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
|
|||||||
@@ -137,6 +137,14 @@
|
|||||||
"unique": false,
|
"unique": false,
|
||||||
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_workflow_execution_transaction_id\" ON \"workflow_execution\" (transaction_id) WHERE deleted_at IS NULL"
|
"expression": "CREATE INDEX IF NOT EXISTS \"IDX_workflow_execution_transaction_id\" ON \"workflow_execution\" (transaction_id) WHERE deleted_at IS NULL"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"keyName": "IDX_workflow_execution_workflow_id_transaction_id_unique",
|
||||||
|
"columnNames": [],
|
||||||
|
"composite": false,
|
||||||
|
"primary": false,
|
||||||
|
"unique": false,
|
||||||
|
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_workflow_execution_workflow_id_transaction_id_unique\" ON \"workflow_execution\" (workflow_id, transaction_id) WHERE deleted_at IS NULL"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"keyName": "IDX_workflow_execution_state",
|
"keyName": "IDX_workflow_execution_state",
|
||||||
"columnNames": [],
|
"columnNames": [],
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
import { Migration } from '@mikro-orm/migrations';
|
||||||
|
|
||||||
|
export class Migration20250120111059 extends Migration {
|
||||||
|
|
||||||
|
async up(): Promise<void> {
|
||||||
|
this.addSql('CREATE UNIQUE INDEX IF NOT EXISTS "IDX_workflow_execution_workflow_id_transaction_id_unique" ON "workflow_execution" (workflow_id, transaction_id) WHERE deleted_at IS NULL;');
|
||||||
|
}
|
||||||
|
|
||||||
|
async down(): Promise<void> {
|
||||||
|
this.addSql('drop index if exists "IDX_workflow_execution_workflow_id_transaction_id_unique";');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -23,6 +23,11 @@ export const WorkflowExecution = model
|
|||||||
on: ["transaction_id"],
|
on: ["transaction_id"],
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
on: ["workflow_id", "transaction_id"],
|
||||||
|
unique: true,
|
||||||
|
where: "deleted_at IS NULL",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
on: ["state"],
|
on: ["state"],
|
||||||
where: "deleted_at IS NULL",
|
where: "deleted_at IS NULL",
|
||||||
|
|||||||
Reference in new issue
Block a user