我在尝试通过我们的测试环境的capistrano配方加载一系列sql文件时遇到了问题。
这就是我的目标:
desc "Empty database and play sql scripts for fresh db structure"
task :mysqlrestore, :roles => :app do
run "find #{current_release}/migration/ -name '*.sql' -print0 | xargs -0 -I file mysql -hlocalhost -u#{db_username} -p#{db_password} #{db_database} < file"
我的capistrano控制台输出:
失败:“sh -c'find / home / toolbox / www / staging / releases / 20120119111819 / migration / -name'\''* .sql'\'' - print0 | xargs -0 -I file mysql - hlocalhost -uuser -ppassword DBNAME&lt; file'“on staging.env.com
我哪里错了?
答案 0 :(得分:1)
只需从运行命令中删除单引号,就可以从bash执行命令。
<强>即强>
run "find #{current_release}/migration/ -name *.sql -print0 | xargs -0 -I file mysql -hlocalhost -u#{db_username} -p#{db_password} #{db_database} < file"