Skip to content

Enum values are not updated when changed #3955

@Luxiorawa

Description

@Luxiorawa

Describe the bug

When defining and using an enum in Entity like this one :

@Entity({ tableName: 'foo' })
export class Foo {
  @PrimaryKey()
  public id: number;

  @Enum({ items: () => FooTypes })
  public type: FooTypes;
}

If i update (add a value, change a value, or even delete one) in my enum that is like this :

export enum FooTypes {
  A = 'A',
  B = 'B',
  C = 'C'
}

Nothing is taken into account. Whether i use schema:update, schema:fresh or even create a migration with migration:create, my changes are not detected.

The only thing that worked, was change the column type, like make it a VARCHAR and reverted it back to the initial Enum it was, and it sucessfully updated.

To Reproduce

I created a repository so that you can better understand the issue, unfortunately i would like to keep a mysql database since it may come from here as well. So you would need to input a real database in the repro unfortunately.

Expected behavior

Enum values should be updated in the database properly

Versions

Dependency Version
node 16.13.0
typescript 4.8.4
mikro-orm 5.6.2
mikro-orm/mysql 5.6.2
nest-js 9.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions