Skip to content

Schema dump produces invalid ruby code with CURRENT_TIMESTAMP column default #28

Description

@phillipp

When you dump a MySQL tablewith schema_plus where a column has "CURRENT_TUIMESTAMP" as the default value, the schema dump contains invalid ruby code:

t.datetime "created",           :default=>#<Proc:0x000055a1df04d748@(eval):1 (lambda)>, :null=>false

This is because the schema dump "converter" in schema_plus/core/active_record/schema_dumper.rb uses eval to make the m[:options]a hash, but that contains a lambda:

SchemaDump::Table::Column.new name: m[:name], type: m[:type], options: eval("{" + m[:options] + "}"), comments: []

Where m[:options] is a string: default: -> { "CURRENT_TIMESTAMP" }, null: false.

I'm not sure what possible solutions look like. Maybe saving the original string and use it for the dump, but use the parsed one for all other purposes? Do you have any ideas?

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