Skip to content

MySql signed primary key migration  #5485

@HermanFassett

Description

@HermanFassett

Describe the bug

I have an entity that has a signed primary key like so:

@PrimaryKey({ autoincrement: false, type: new BigIntType('bigint'), unsigned: false })`
id!: number;

I am trying to use in another class as a ManyToOne reference, but in the generated migrations, the generated foreign key user_id is of type unsigned so running the migration fails with error Referencing column 'user_id' and referenced column 'id' in foreign key constraint 'message_user_id_foreign' are incompatible (or similar error, in repro the error is a missing index). Am I missing something that can get this working?

Reproduction

https://github.com/HermanFassett/mikro-orm-repro/

What driver are you using?

@mikro-orm/mysql

MikroORM version

6.2.2

Node.js version

20.12.0

Operating system

Windows 10

Validations

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