Skip to content

dump/load doesn't work with MySQL virtual columns #140

Open
@octavpo

Description

@octavpo

I have a table that looks like:

    create_table :skills do |t|
      t.string :name, null: false
      t.string :category, null: false
      t.virtual :identity, type: :string, as: "concat_ws('/', name, category)"
      ...
    end

db:data:dump dumps the virtual column values fine, but when I try to load them with db:data:load I get an error from MySQL:

Mysql2::Error: The value specified for generated column 'identity' in table 'skills' is not allowed.

It looks like MySQL wants to recreate the virtual values dynamically on load, so it doesn't accept values being given for them in INSERT. After I deleted the values from the data.yaml file, I could load it fine.

So the utility should either skip virtual columns on dump, or skip them on load.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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