tableList as $key => $table) { if ($schema->getTable($this->prefix.$table)->hasColumn($this->uuidColumn)) { unset($this->tableList[$key]); } } } public function up(Schema $schema): void { if (0 === count($this->tableList)) { return; } $statements = []; foreach ($this->tableList as $table) { // When we migrate to MySql 8.0.13+, // the below commented statement would suffice for settings default values using expression // ALTER TABLE `{$this->prefix}{$table}` ALTER `{$this->uuidColumn}` SET DEFAULT bin_to_uuid(UUID()); $statements[] = "ALTER TABLE `{$this->prefix}{$table}` ADD COLUMN `{$this->uuidColumn}` char(36) default NULL;"; $statements[] = "UPDATE `{$this->prefix}{$table}` SET `{$this->uuidColumn}` = UUID() WHERE `{$this->uuidColumn}` IS NULL;"; } $batchSql = implode(' ', $statements); $this->addSql($batchSql); } }