mikro-orm icon indicating copy to clipboard operation
mikro-orm copied to clipboard

Adding a proprty option to @Enum drops existing check constraint with PostgreSQL driver

Open yeedle opened this issue 2 years ago • 0 comments

Describe the bug When adding a PropertyOption (e.g. comment) to an existing @Enum decorator, it causes the PostgreSQL driver to drop it if it already exists.

To Reproduce Steps to reproduce the behavior:

  1. declare an enum and generate a migration
@Enum(() => SomeEnum)
someEnum: SomeEnum
  1. Update it as follows and generate another migration
@Enum({ items: () => SomeEnum, comment: 'this is a comment' })
someEnum: SomeEnum
  1. The second migration will have generated SQL to drop the check constraint generated by the first one

Expected behavior Adding property options in the @Enum decorator unrelated to the enum, should not cause constraint dropping.

Additional context Seems to me like the bug comes from here where every change in the property options will cause it to drop the constraint, even if the change is unrelated to the constraint.

Versions

Dependency Version
node 16.14.2
typescript 1.22.15
mikro-orm 5.6.8
your-driver PostgreSQL

yeedle avatar Mar 09 '23 19:03 yeedle