Mysql
 sql >> Datenbank >  >> RDS >> Mysql

Importieren Sie MySQL-DB-Dump mithilfe einer Migrationsdatei in eine Rails-App

Es liegt an mir zu beurteilen, warum ich von mysql auf sqlite3 db migriere. Warum führen Sie Ihre Entwicklungsumgebung nicht auch in MySQL aus? Wie auch immer, das Folgende ist das Skript.

#!/bin/sh 

mysqldump --compact --compatible=ansi --default-character-set=binary mydbname | 
grep -v ' KEY "' | 
grep -v ' UNIQUE KEY "' | 
perl -e 'local $/;$_=<>;s/,\n\)/\n\)/gs;print "begin;\n";print;print "commit;\n"' | 
perl -pe ' 
if (/^(INSERT.+?)\(/) { 
$a=$1; 
s/\\'\''/'\'\''/g; 
s/\\n/\n/g; 
s/\),\(/\);\n$a\(/g; 
} ' | sqlite3 output.db