Skip to content

typeorm index & unique #46

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

Open
cjaewon opened this issue May 20, 2020 · 0 comments
Open

typeorm index & unique #46

cjaewon opened this issue May 20, 2020 · 0 comments

Comments

@cjaewon
Copy link

cjaewon commented May 20, 2020

// User.ts
  @Index()
  @Column({ unique: true, length: 255 })
  username!: string;

  @Index()
  @Column({ unique: true, length: 255, nullable: true, type: 'varchar' })
  email!: string | null;

SYNC가 true일 때
unique에는 index가 내장되어 있어서 @Index를 하면 duplicate key 오류가 나오는데

@Column 에서 unique를 빼주거나 @Index({ unique: true }) 또는
@Index를 제거해주고 @Column({ unique: true }) 로 해야 할 것 같습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant