chore: Move customer + customer group integration tests and fixes issues (#7577)
* chore: Move customer + customer group and fixes issues * remove /customer sendpoint
This commit is contained in:
@@ -388,7 +388,7 @@
|
||||
"unsigned": false,
|
||||
"autoincrement": false,
|
||||
"primary": false,
|
||||
"nullable": true,
|
||||
"nullable": false,
|
||||
"mappedType": "text"
|
||||
},
|
||||
"metadata": {
|
||||
@@ -445,6 +445,16 @@
|
||||
"name": "customer_group",
|
||||
"schema": "public",
|
||||
"indexes": [
|
||||
{
|
||||
"keyName": "IDX_customer_group_name_unique",
|
||||
"columnNames": [
|
||||
"name"
|
||||
],
|
||||
"composite": false,
|
||||
"primary": false,
|
||||
"unique": false,
|
||||
"expression": "CREATE UNIQUE INDEX IF NOT EXISTS \"IDX_customer_group_name_unique\" ON \"customer_group\" (name) WHERE deleted_at IS NULL"
|
||||
},
|
||||
{
|
||||
"keyName": "customer_group_pkey",
|
||||
"columnNames": [
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import { Migration } from "@mikro-orm/migrations"
|
||||
|
||||
export class Migration20240602110946 extends Migration {
|
||||
async up(): Promise<void> {
|
||||
this.addSql(
|
||||
'ALTER TABLE IF EXISTS "customer_group" ALTER COLUMN "name" SET NOT NULL;'
|
||||
)
|
||||
this.addSql(
|
||||
'CREATE UNIQUE INDEX IF NOT EXISTS "IDX_customer_group_name_unique" ON "customer_group" (name) WHERE deleted_at IS NULL;'
|
||||
)
|
||||
}
|
||||
|
||||
async down(): Promise<void> {
|
||||
this.addSql(
|
||||
'ALTER TABLE IF EXISTS "customer_group" ALTER COLUMN "name" DROP NOT NULL;'
|
||||
)
|
||||
this.addSql('drop index if exists "IDX_customer_group_name_unique";')
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,33 @@
|
||||
import { DAL } from "@medusajs/types"
|
||||
import { DALUtils, Searchable, generateEntityId } from "@medusajs/utils"
|
||||
import {
|
||||
DALUtils,
|
||||
Searchable,
|
||||
createPsqlIndexStatementHelper,
|
||||
generateEntityId,
|
||||
} from "@medusajs/utils"
|
||||
import {
|
||||
BeforeCreate,
|
||||
Collection,
|
||||
Entity,
|
||||
Filter,
|
||||
ManyToMany,
|
||||
OnInit,
|
||||
OptionalProps,
|
||||
PrimaryKey,
|
||||
Property,
|
||||
ManyToMany,
|
||||
Collection,
|
||||
Filter,
|
||||
} from "@mikro-orm/core"
|
||||
import Customer from "./customer"
|
||||
import CustomerGroupCustomer from "./customer-group-customer"
|
||||
|
||||
type OptionalGroupProps = DAL.SoftDeletableEntityDateColumns // TODO: To be revisited when more clear
|
||||
|
||||
const CustomerGroupUniqueName = createPsqlIndexStatementHelper({
|
||||
tableName: "customer_group",
|
||||
columns: ["name"],
|
||||
unique: true,
|
||||
where: "deleted_at IS NULL",
|
||||
})
|
||||
|
||||
@Entity({ tableName: "customer_group" })
|
||||
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
|
||||
export default class CustomerGroup {
|
||||
@@ -25,8 +37,9 @@ export default class CustomerGroup {
|
||||
id!: string
|
||||
|
||||
@Searchable()
|
||||
@Property({ columnType: "text", nullable: true })
|
||||
name: string | null = null
|
||||
@CustomerGroupUniqueName.MikroORMIndex()
|
||||
@Property({ columnType: "text" })
|
||||
name: string
|
||||
|
||||
@ManyToMany({
|
||||
entity: () => Customer,
|
||||
|
||||
Reference in New Issue
Block a user