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

Already on GitHub? Sign in to your account

Rake task 'db:structure:dump' and mysql/oracle #5547

Closed
e1senh0rn opened this Issue Mar 22, 2012 · 2 comments

Comments

Projects
None yet
4 participants

For mysql/oracle rake task db:structure:dump has it's own dumper implementation, but for other databases it uses external utils to build dump.

And it does matter when you use views/triggers/procedures with mysql: tests are simply failing because mentioned objects are missing in test db after dump/load.

Is there any reason why not to use mysqldump instead of custom dumper?

I'm not familiar with oracle utils, but I think there should be something similar too.

corny commented Jun 1, 2012

I have to deal with this lack of support for dumping triggers as well. I fixed it with the following code for the mysql2 adapter:

module TriggerDumper
  def structure_dump
    super << select_all("SHOW TRIGGERS").map { |trigger|
      exec_without_stmt("SHOW CREATE TRIGGER #{trigger['Trigger']}").first['SQL Original Statement'].sub(/DEFINER=\S+ /,'') << "\n\n"
    }.join
  end
end

ActiveRecord::ConnectionAdapters::Mysql2Adapter.send :include, TriggerDumper
Contributor

kennyj commented Jun 3, 2012

Hi ! @daemon and @corny .
I think I fixed this issue (sorry only mysql)
Please review it !

I tested my fix, and it's work fine. But I don't know a testcase where that should be included ;-)
And I also know we have security problem (in line password), should we use include_password option (like dbconsole) ?

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