Skip to content

Migration from MySQL not working as expected given default casts #1123

Closed
@cheslijones

Description

@cheslijones
  • pgloader --version

    pgloader version "3.6.1"
    compiled with SBCL 1.4.0-1.el7
    

I noticed auto_increments were not coming over as expected (SERIAL) into Postgres. I'm just using the following command to do the migration:

./pgloader mysql://<db_user>:'<database_password>'@localhost/<db_name> postgres://<db_user>:'<database_password>'@localhost/<db_name>`

I might have <db_user> and <db_name> reversed, but anyway...
Looking at the field in question in MySQL shows:

image

But ends up in Postgres as:

image

Thought it was a bug until I started reading the documentation and the default casts:

type int with extra auto_increment to serial when (< precision 10)
type int with extra auto_increment to bigserial when (<= 10 precision)
type int to int       when  (< precision 10)
type int to bigint    when  (>= 10 precision)

Based on this, that it came into Postgres as bigint makes sense, since it meets the (>=10 precision) criteria.

However, looking at this one:

type int with extra auto_increment to bigserial when (<= 10 precision)

Should it actually be:

type int with extra auto_increment to bigserial when (>= 10 precision)

It seems like the only criteria for bigserial would just be when int(10) and anything over that would just come over as bigint.

Is my thinking wrong on this?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions