Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
phillipp opened this issue Jun 26, 2021 · 1 comment

Comments

@phillipp
Copy link

phillipp commented Jun 26, 2021

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?

@atomical
Copy link

I've run into this too. I've got a working solution but now I have an index issue to fix with as well.

master...atomical:schema_plus_core:support_for_default_procs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants