Преглед изворни кода

feat(core): Make ProductOptionGroup / ProductOption soft-deletable

Relates to #291

BREAKING CHANGE: The ProductOptionGroup & ProductOption entities have a new `deletedAt` column
which will require a DB migration.
Michael Bromley пре 5 година
родитељ
комит
0c997bf352

+ 6 - 1
packages/core/src/entity/product-option-group/product-option-group.entity.ts

@@ -1,6 +1,7 @@
 import { DeepPartial } from '@vendure/common/lib/shared-types';
 import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
 
+import { SoftDeletable } from '../../common/types/common-types';
 import { LocaleString, Translatable, Translation } from '../../common/types/locale-types';
 import { HasCustomFields } from '../../config/custom-field/custom-field-types';
 import { VendureEntity } from '../base/base.entity';
@@ -17,10 +18,14 @@ import { ProductOptionGroupTranslation } from './product-option-group-translatio
  * @docsCategory entities
  */
 @Entity()
-export class ProductOptionGroup extends VendureEntity implements Translatable, HasCustomFields {
+export class ProductOptionGroup
+    extends VendureEntity
+    implements Translatable, HasCustomFields, SoftDeletable {
     constructor(input?: DeepPartial<ProductOptionGroup>) {
         super(input);
     }
+    @Column({ type: Date, nullable: true })
+    deletedAt: Date | null;
 
     name: LocaleString;
 

+ 4 - 1
packages/core/src/entity/product-option/product-option.entity.ts

@@ -1,6 +1,7 @@
 import { DeepPartial, ID } from '@vendure/common/lib/shared-types';
 import { Column, Entity, ManyToOne, OneToMany } from 'typeorm';
 
+import { SoftDeletable } from '../../common/types/common-types';
 import { LocaleString, Translatable, Translation } from '../../common/types/locale-types';
 import { HasCustomFields } from '../../config/custom-field/custom-field-types';
 import { VendureEntity } from '../base/base.entity';
@@ -17,10 +18,12 @@ import { ProductOptionTranslation } from './product-option-translation.entity';
  * @docsCategory entities
  */
 @Entity()
-export class ProductOption extends VendureEntity implements Translatable, HasCustomFields {
+export class ProductOption extends VendureEntity implements Translatable, HasCustomFields, SoftDeletable {
     constructor(input?: DeepPartial<ProductOption>) {
         super(input);
     }
+    @Column({ type: Date, nullable: true })
+    deletedAt: Date | null;
 
     name: LocaleString;