Skip to content

Specify enum type name in postgres #4106

@lgyanf

Description

@lgyanf

Issue type:

[x] question
[ ] 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:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

I'm thinking to migrate my application from Sequelize to TypeORM, as a first step I've tried to reimplement current Sequelize models to TypeORM.
I've encountered an issue that Sequelize and TypeORM generate postgres' enum type names differrently: Sequelize uses pattern 'enum_${tableName}_${columnName}' whereas TypeORM uses '${tableName}_${columnName}_enum'.toLowerCase(). Is there a way I can specify custom type name in TypeORM's model definition?
If not, would it be useful to be able to specify type name in column definition? Something like

@Column({
    type: 'enum',
    typeName: 'my_enum',
    enum: MyEnum,
})
enum_column: MyEnum

This would also allow to reuse same postgres enum type across multiple columns.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions