11<?php
22
33use Cake \Error \Debugger ;
4+ use Phinx \Db \Adapter \AdapterInterface ;
5+ use Phinx \Db \Adapter \AdapterWrapper ;
46use Phinx \Db \Adapter \MysqlAdapter ;
57use Phinx \Migration \AbstractMigration ;
68
@@ -16,7 +18,7 @@ class Utf8mb4Fix extends AbstractMigration {
1618 *
1719 * @return void
1820 */
19- public function change () {
21+ public function change (): void {
2022 $ table = $ this ->table ('queue_processes ' );
2123 $ table ->changeColumn ('pid ' , 'string ' , [
2224 'length ' => 40 ,
@@ -64,9 +66,8 @@ public function change() {
6466 'collation ' => 'utf8mb4_unicode_ci ' ,
6567 ]);
6668 $ table ->update ();
67-
6869 //TODO: check adapter and skip for postgres, instead of try/catch
69- if ($ this ->adapter instanceof MysqlAdapter) {
70+ if ($ this ->getUnwrappedAdapter () instanceof MysqlAdapter) {
7071 try {
7172 $ table = $ this ->table ('queued_jobs ' );
7273 $ table ->changeColumn ('data ' , 'text ' , [
@@ -90,4 +91,19 @@ public function change() {
9091 }
9192 }
9293
94+ /**
95+ * Gets the unwrapped adapter
96+ *
97+ * @return \Phinx\Db\Adapter\AdapterInterface|null
98+ */
99+ private function getUnwrappedAdapter (): ?AdapterInterface {
100+ $ adapter = $ this ->adapter ;
101+
102+ while ($ adapter instanceof AdapterWrapper) {
103+ $ adapter = $ adapter ->getAdapter ();
104+ }
105+
106+ return $ adapter ;
107+ }
108+
93109}
0 commit comments