Mikro-orm: Including parent table in STI discriminator map causes empty migrations

Created on 25 Sep 2020  路  4Comments  路  Source: mikro-orm/mikro-orm

Describe the bug
When creating a single table inheritance set up where the parent table is included in the discriminatorMap property, generated migrations ignore all the tables. If the parent table is removed from the map - the migrations run correctly.

To Reproduce
Steps to reproduce the behavior:

  1. Reproduction: https://github.com/alisd23/mikro-orm-nestjs-starter/tree/bug/sti-migration
  2. Run migration:create command (info about setup and running commands in README.md) with parent included in discriminatorMap
  3. See new empty migration

With this child table:

// employee.entity.ts
@Entity()
export class Employee extends Person {
  @Property()
  number: number;
}

This works:

// person.entity.ts
@Entity({
  discriminatorColumn: 'type',
  discriminatorMap: {
    // person: 'Person',
    employee: 'Employee',
  },
})
export class Person {
  @PrimaryKey()
  id: string;
}

However this causes empty migrations:

// person.entity.ts
@Entity({
  discriminatorColumn: 'type',
  discriminatorMap: {
    person: 'Person',
    employee: 'Employee',
  },
})
export class Person {
  @PrimaryKey()
  id: string;
}

Versions

| Dependency | Version |
| - | - |
| node | 12.18.3 |
| typescript | 4.0.x |
| mikro-orm | 4.0.7 |
| your-driver | mysql2 |

bug

Most helpful comment

Later this week, will be aiming for the first half (tue/wed), but can't promise.

All 4 comments

@B4nan Do you have an ETA for release of the commits fixing this issue?

Later this week, will be aiming for the first half (tue/wed), but can't promise.

@B4nan I made the same fix as you applied here, and it appears to me that in MySQL any sort of many-many pivot table is no longer generated using the migration:create --initial command.

Was this page helpful?
0 / 5 - 0 ratings