Skip to content

Commit

Permalink
feat(core): Added a unique index to Order.code
Browse files Browse the repository at this point in the history
  • Loading branch information
skid authored and michaelbromley committed Apr 1, 2022
1 parent b882b91 commit aa6025d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/entity/order/order.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@vendure/common/lib/generated-types';
import { DeepPartial, ID } from '@vendure/common/lib/shared-types';
import { summate } from '@vendure/common/lib/shared-utils';
import { Column, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany } from 'typeorm';
import { Column, Entity, Index, JoinTable, ManyToMany, ManyToOne, OneToMany } from 'typeorm';

import { Calculated } from '../../common/calculated-decorator';
import { InternalServerError } from '../../common/error/errors';
Expand Down Expand Up @@ -51,7 +51,9 @@ export class Order extends VendureEntity implements ChannelAware, HasCustomField
* {@link OrderCodeStrategy}. This should be used as an order reference
* for Customers, rather than the Order's id.
*/
@Column() code: string;
@Column()
@Index({ unique: true })
code: string;

@Column('varchar') state: OrderState;

Expand Down

0 comments on commit aa6025d

Please sign in to comment.