-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Description
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[ ] latest
[ ] @next
[x] 0.2.22
[x] 0.2.24
Steps to reproduce or a small repository showing the problem:
- Create the following schema with previous migrations (no problems there):
export enum UserLoginMethod {
DeviceId = "device_id",
Facebook = "facebook",
Bot = "bot"
}
@Entity()
// We have to create a composite index for it to be a target of a foregn key
@Index("user_login_method", ["id", "loginMethod"], { unique: true })
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column({
type: "enum",
enum: UserLoginMethod
})
loginMethod: UserLoginMethod;
}- Create a new entity:
@Entity()
export class UserDeviceId {
@OneToOne(type => User, { primary: true })
@JoinColumn([
{ name: "userId", referencedColumnName: "id" },
{ name: "userLoginMethod", referencedColumnName: "loginMethod"}
])
user: User;
@Column({ unique: true })
@Index()
deviceId: string;
}- Try to generate a new migration:
typeorm migration:generate -n UserDeviceId
Expected result:
A new migration is created, with a new table that uses a composite foreign key as a primary column.
Actual result:
Error during migration generation:
TypeError: Cannot read property 'map' of undefined
at PostgresQueryRunner.createEnumTypeSql (/usr/lib/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:2398:38)
at PostgresQueryRunner.<anonymous> (/usr/lib/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:420:69) at step (/usr/lib/node_modules/typeorm/node_modules/tslib/tslib.js:136:27)
at Object.next (/usr/lib/node_modules/typeorm/node_modules/tslib/tslib.js:117:57)
at fulfilled (/usr/lib/node_modules/typeorm/node_modules/tslib/tslib.js:107:62)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
Reactions are currently unavailable