Skip to content

Shared enums #4741

@ejose19

Description

@ejose19

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:

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

Steps to reproduce or a small repository showing the problem:

Is there a way to consolidate a shared enum like:

GenderEnum.ts

export enum Gender {
    male = 'male',
    female = 'female'
}

Used by 2 or more classes like Human.ts / Animal.ts in the database? Currently typeorm creates both human_gender_enum and animal_gender_enum even thought both are the same, so it's redundant to have different enums in the database.
If I create the enum type and tables directly in postgres this doesn't happen (only 1 enum is generated)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions