Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeORM error - DataTypeNotSupportedError

My entity file: user.ts:

@Entity('users')
export class User {
  @PrimaryGeneratedColumn()
  id: number | undefined;

  @Column({ type: 'string', name: 'username', nullable: true })
  username: string | undefined;

  @Column()
  password: string | undefined;

  @CreateDateColumn()
  createdAt: Date | undefined;

  @UpdateDateColumn()
  updatedAt: Date | undefined;
}

I'm getting the following error: 'Data type "string" in "User.username" is not supported by "mysql" database.'

Tried to search within typeorm issues tracker on a github, but there was no answers that would solve this issue. I run my project using tsc-watch

like image 849
Alexander Kim Avatar asked Aug 16 '26 07:08

Alexander Kim


1 Answers

This is the correct usage:

@Column({ type: 'varchar', nullable: true })
username: string | undefined;
like image 119
TJ H. Avatar answered Aug 17 '26 21:08

TJ H.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!