feat(client-types, types, medusa, inventory): Inventory item and reservation item datamodel updates (#3971)
* add fields * add title in migration * update api endpoints to reflect datamodel changes * update migration exports for inventory module * add changeset * add created_by for reservation item
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import * as setup from "./schema-migrations/1665748086258-inventory_setup"
|
||||
import * as addExternalId from "./schema-migrations/1675761451145-add_reservation_external_id"
|
||||
import * as descriptionsAndThumbnail from "./schema-migrations/1682927363119-item_descriptions_and_thumbnail"
|
||||
import * as setup from "./schema-migrations/1665748086258-inventory_setup"
|
||||
|
||||
export default [setup, addExternalId]
|
||||
export default [setup, addExternalId, descriptionsAndThumbnail]
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||
|
||||
export class itemDescriptionsAndThumbnail1682927363119
|
||||
implements MigrationInterface
|
||||
{
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE inventory_item
|
||||
ADD "title" character varying,
|
||||
ADD "description" character varying,
|
||||
ADD "thumbnail" character varying;
|
||||
`)
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "reservation_item"
|
||||
ADD "description" character varying,
|
||||
ADD "created_by" character varying;
|
||||
`)
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE reservation_item
|
||||
DROP COLUMN "title",
|
||||
DROP COLUMN "description",
|
||||
DROP COLUMN "thumbnail";
|
||||
`)
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE "reservation_item"
|
||||
DROP COLUMN "description",
|
||||
DROP COLUMN "created_by";
|
||||
`)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import { generateEntityId, SoftDeletableEntity } from "@medusajs/utils"
|
||||
import { BeforeInsert, Column, Entity, Index } from "typeorm"
|
||||
import { SoftDeletableEntity, generateEntityId } from "@medusajs/utils"
|
||||
|
||||
@Entity()
|
||||
export class InventoryItem extends SoftDeletableEntity {
|
||||
@@ -34,6 +34,15 @@ export class InventoryItem extends SoftDeletableEntity {
|
||||
@Column({ default: true })
|
||||
requires_shipping: boolean
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
description: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
title: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
thumbnail: string | null
|
||||
|
||||
@Column({ type: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown> | null
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { generateEntityId, SoftDeletableEntity } from "@medusajs/utils"
|
||||
import { BeforeInsert, Column, Entity, Index } from "typeorm"
|
||||
import { SoftDeletableEntity, generateEntityId } from "@medusajs/utils"
|
||||
|
||||
@Entity()
|
||||
export class ReservationItem extends SoftDeletableEntity {
|
||||
@@ -21,6 +21,12 @@ export class ReservationItem extends SoftDeletableEntity {
|
||||
@Column({ type: "text", nullable: true })
|
||||
external_id: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
description: string | null
|
||||
|
||||
@Column({ type: "text", nullable: true })
|
||||
created_by: string | null
|
||||
|
||||
@Column({ type: "jsonb", nullable: true })
|
||||
metadata: Record<string, unknown> | null
|
||||
|
||||
|
||||
@@ -135,6 +135,9 @@ export default class InventoryItemService {
|
||||
height: data.height,
|
||||
width: data.width,
|
||||
requires_shipping: data.requires_shipping,
|
||||
description: data.description,
|
||||
thumbnail: data.thumbnail,
|
||||
title: data.title,
|
||||
})
|
||||
|
||||
const result = await itemRepository.save(inventoryItem)
|
||||
|
||||
@@ -141,6 +141,8 @@ export default class ReservationItemService {
|
||||
quantity: data.quantity,
|
||||
metadata: data.metadata,
|
||||
external_id: data.external_id,
|
||||
description: data.description,
|
||||
created_by: data.created_by,
|
||||
})
|
||||
|
||||
const [newReservationItem] = await Promise.all([
|
||||
|
||||
Reference in New Issue
Block a user