To create separate unique constraints on both userguid and username columns in TypeORM, you don't need to use the @Unique decorator at the class level. Instead, you can apply the @Unique decorator at the property level for each column.
So you can change from this:
@Entity({ name: "USERS" })
@Unique("USERS_UQ", ["userName"])
export class UserORM {...}
To:
@Entity({ name: "USERS" })
export class UserORM {
...
@Column({
name: "USERGUID",
type: "varchar2",
length: 256,
nullable: false,
})
@Unique("USERS_UQ_USERGUID", ["userGUID"])
userGUID!: string;
@Column({
name: "USERNAME",
type: "varchar2",
length: 256,
nullable: false,
})
@Unique("USERS_UQ_USERNAME", ["userName"])
userName!: string;
...
}
This approach generates two distinct UNIQUE constraints for the userguid and username columns when you synchronize your database schema.