Skip to content

Instantly share code, notes, and snippets.

@catatsuy
Created February 5, 2016 02:51
Show Gist options
  • Select an option

  • Save catatsuy/16771229e2d7727988e0 to your computer and use it in GitHub Desktop.

Select an option

Save catatsuy/16771229e2d7727988e0 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
for (<>) {
if (/\ACREATE TABLE ([`a-zA-Z0-9_]+)/) {
print "\nALTER TABLE " . $1 . "\n";
} elsif (/\A[ ]+([`a-zA-Z0-9_]+) (varchar\(\d+\)|mediumtext|text)(( NOT NULL,)?)/) {
if ($3) {
print " MODIFY " . $1 . " " . $2 . " CHARACTER SET utf8mb4 NOT NULL,\n";
} else {
print " MODIFY " . $1 . " " . $2 . " CHARACTER SET utf8mb4,\n";
}
} elsif (/\A\) ENGINE=InnoDB/) {
print "DEFAULT CHARACTER SET utf8mb4 ENGINE=Innodb;\n";
}
}
@catatsuy

Copy link
Copy Markdown
Author

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