feat(order): Add display_id to order table (#7242)
Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
1 parent
5443c69794
commit
cf9605fe6f
6 files changed
+633
-132
No files matched your search
@@ -153,6 +153,7 @@ medusaIntegrationTestRunner({
|
|||||||
id: expect.any(String),
|
id: expect.any(String),
|
||||||
status: "pending",
|
status: "pending",
|
||||||
version: 1,
|
version: 1,
|
||||||
|
display_id: 1,
|
||||||
summary: expect.objectContaining({
|
summary: expect.objectContaining({
|
||||||
// TODO: add all summary fields
|
// TODO: add all summary fields
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
export const defaultAdminOrderFields = [
|
export const defaultAdminOrderFields = [
|
||||||
"id",
|
"id",
|
||||||
|
"display_id",
|
||||||
"status",
|
"status",
|
||||||
"version",
|
"version",
|
||||||
"summary",
|
"summary",
|
||||||
@@ -10,6 +11,7 @@ export const defaultAdminOrderFields = [
|
|||||||
|
|
||||||
export const defaultAdminRetrieveOrderFields = [
|
export const defaultAdminRetrieveOrderFields = [
|
||||||
"id",
|
"id",
|
||||||
|
"display_id",
|
||||||
"status",
|
"status",
|
||||||
"version",
|
"version",
|
||||||
"summary",
|
"summary",
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ moduleIntegrationTestRunner({
|
|||||||
const expectation = expect.objectContaining({
|
const expectation = expect.objectContaining({
|
||||||
id: expect.stringContaining("order_"),
|
id: expect.stringContaining("order_"),
|
||||||
version: 1,
|
version: 1,
|
||||||
|
display_id: 1,
|
||||||
summary: expect.objectContaining({
|
summary: expect.objectContaining({
|
||||||
// TODO: add all summary fields
|
// TODO: add all summary fields
|
||||||
}),
|
}),
|
||||||
@@ -203,6 +204,7 @@ moduleIntegrationTestRunner({
|
|||||||
const getOrder = await service.retrieve(createdOrder.id, {
|
const getOrder = await service.retrieve(createdOrder.id, {
|
||||||
select: [
|
select: [
|
||||||
"id",
|
"id",
|
||||||
|
"display_id",
|
||||||
"version",
|
"version",
|
||||||
"items.id",
|
"items.id",
|
||||||
"summary",
|
"summary",
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -30,6 +30,7 @@ export class Migration20240219102530 extends Migration {
|
|||||||
CREATE TABLE IF NOT EXISTS "order" (
|
CREATE TABLE IF NOT EXISTS "order" (
|
||||||
"id" TEXT NOT NULL,
|
"id" TEXT NOT NULL,
|
||||||
"region_id" TEXT NULL,
|
"region_id" TEXT NULL,
|
||||||
|
"display_id" SERIAL,
|
||||||
"customer_id" TEXT NULL,
|
"customer_id" TEXT NULL,
|
||||||
"version" INTEGER NOT NULL DEFAULT 1,
|
"version" INTEGER NOT NULL DEFAULT 1,
|
||||||
"sales_channel_id" TEXT NULL,
|
"sales_channel_id" TEXT NULL,
|
||||||
@@ -111,6 +112,11 @@ export class Migration20240219102530 extends Migration {
|
|||||||
"DROP NOT NULL"
|
"DROP NOT NULL"
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
CREATE INDEX IF NOT EXISTS "IDX_order_display_id" ON "order" (
|
||||||
|
display_id
|
||||||
|
)
|
||||||
|
WHERE deleted_at IS NOT NULL;
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS "IDX_order_region_id" ON "order" (
|
CREATE INDEX IF NOT EXISTS "IDX_order_region_id" ON "order" (
|
||||||
region_id
|
region_id
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ type OptionalOrderProps =
|
|||||||
| "billing_address"
|
| "billing_address"
|
||||||
| DAL.EntityDateColumns
|
| DAL.EntityDateColumns
|
||||||
|
|
||||||
|
const DisplayIdIndex = createPsqlIndexStatementHelper({
|
||||||
|
tableName: "order",
|
||||||
|
columns: "display_id",
|
||||||
|
where: "deleted_at IS NOT NULL",
|
||||||
|
})
|
||||||
|
|
||||||
const RegionIdIndex = createPsqlIndexStatementHelper({
|
const RegionIdIndex = createPsqlIndexStatementHelper({
|
||||||
tableName: "order",
|
tableName: "order",
|
||||||
columns: "region_id",
|
columns: "region_id",
|
||||||
@@ -83,6 +89,10 @@ export default class Order {
|
|||||||
@PrimaryKey({ columnType: "text" })
|
@PrimaryKey({ columnType: "text" })
|
||||||
id: string
|
id: string
|
||||||
|
|
||||||
|
@Property({ autoincrement: true, primary: false })
|
||||||
|
@DisplayIdIndex.MikroORMIndex()
|
||||||
|
display_id: number
|
||||||
|
|
||||||
@Property({
|
@Property({
|
||||||
columnType: "text",
|
columnType: "text",
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|||||||
Reference in new issue
Block a user