fix nullable description

This commit is contained in:
olivermrbl
2021-03-29 11:45:30 +02:00
parent 38521169c0
commit 3b801e7486
3 changed files with 16 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ describe("POST /admin/discounts", () => {
payload: {
code: "TEST",
rule: {
description: "Test",
type: "fixed",
value: 10,
allocation: "total",
@@ -33,6 +34,7 @@ describe("POST /admin/discounts", () => {
expect(DiscountServiceMock.create).toHaveBeenCalledWith({
code: "TEST",
rule: {
description: "Test",
type: "fixed",
value: 10,
allocation: "total",
@@ -51,6 +53,7 @@ describe("POST /admin/discounts", () => {
payload: {
code: "10%OFF",
rule: {
description: "Test",
value: 10,
allocation: "total",
},

View File

@@ -14,6 +14,12 @@ export class discountUsage1617002207608 implements MigrationInterface {
await queryRunner.query(
`ALTER TABLE "discount" ADD "usage_count" integer NOT NULL DEFAULT '0'`
)
await queryRunner.query(
`ALTER TABLE "discount_rule" ALTER COLUMN "description" DROP NOT NULL`
)
await queryRunner.query(
`COMMENT ON COLUMN "discount_rule"."description" IS NULL`
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
@@ -25,5 +31,11 @@ export class discountUsage1617002207608 implements MigrationInterface {
await queryRunner.query(
`ALTER TABLE "discount_rule" ADD "usage_limit" integer`
)
await queryRunner.query(
`COMMENT ON COLUMN "discount_rule"."description" IS NULL`
)
await queryRunner.query(
`ALTER TABLE "discount_rule" ALTER COLUMN "description" SET NOT NULL`
)
}
}

View File

@@ -30,7 +30,7 @@ export class DiscountRule {
@PrimaryColumn()
id: string
@Column()
@Column({ nullable: true })
description: string
@Column({