Skip to content

Instantly share code, notes, and snippets.

@winebarrel
Created May 28, 2016 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save winebarrel/8651edb841cdd7eefa5ab65158466acc to your computer and use it in GitHub Desktop.
Save winebarrel/8651edb841cdd7eefa5ab65158466acc to your computer and use it in GitHub Desktop.
pt-osc+migration
class PtOsc < Arproxy::Base
def execute(sql, name=nil)
if sql =~ %r|\A/\*\ pt\-osc\ \*/(.+)|
info = JSON.parse($1)
system(
'pt-online-schema-change',
'--alter', info['alter'],
"D=hello_development,t=#{info['table']}",
'--recursion-method', 'none',
'--user', 'root',
'--execute')
nil
else
super(sql, name)
end
end
end
Arproxy.configure do |config|
config.adapter = "mysql2"
config.use PtOsc
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment