-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(core): Administrator soft delete constraint error (#1523) #3890
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { DeepPartial } from '@vendure/common/lib/shared-types'; | ||
| import { Column, Entity, JoinColumn, OneToOne } from 'typeorm'; | ||
| import { Column, Entity, JoinColumn, OneToOne, Unique } from 'typeorm'; | ||
|
|
||
| import { SoftDeletable } from '../../common/types/common-types'; | ||
| import { HasCustomFields } from '../../config/custom-field/custom-field-types'; | ||
|
|
@@ -16,6 +16,7 @@ import { User } from '../user/user.entity'; | |
| * @docsCategory entities | ||
| */ | ||
| @Entity() | ||
| @Unique(['emailAddress', 'isCurrent']) | ||
| export class Administrator extends VendureEntity implements SoftDeletable, HasCustomFields { | ||
| constructor(input?: DeepPartial<Administrator>) { | ||
| super(input); | ||
|
|
@@ -28,9 +29,12 @@ export class Administrator extends VendureEntity implements SoftDeletable, HasCu | |
|
|
||
| @Column() lastName: string; | ||
|
|
||
| @Column({ unique: true }) | ||
| @Column() | ||
| emailAddress: string; | ||
|
|
||
| @Column({ type: 'boolean', default: true, nullable: true }) | ||
| isCurrent: true | null; | ||
|
Comment on lines
+35
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify type safety: TypeScript The TypeScript type is
Consider using If you want to keep the current pattern, add a comment explaining why only + // isCurrent can only be true (for active administrators) or null (for soft-deleted ones)
+ // This constraint allows multiple soft-deleted administrators with the same email address
@Column({ type: 'boolean', default: true, nullable: true })
isCurrent: true | null;🤖 Prompt for AI Agents |
||
|
|
||
| @OneToOne(type => User) | ||
| @JoinColumn() | ||
| user: User; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.