-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
documentation update
- Loading branch information
Vítězslav Dvořák
committed
Dec 17, 2024
1 parent
9df8e85
commit a513284
Showing
4 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
use Phinx\Migration\AbstractMigration; | ||
|
||
final class MySQLutf8mb4 extends AbstractMigration | ||
{ | ||
public function change(): void | ||
{ | ||
// Check if the database is MySQL | ||
$databaseType = $this->getAdapter()->getOption('adapter'); | ||
if ($databaseType === 'mysql') { | ||
// Apply utf8mb4 character set to the database | ||
$this->execute("ALTER DATABASE `" . $this->getAdapter()->getOption('name') . "` CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci"); | ||
|
||
// Apply utf8mb4 character set to all tables | ||
$tables = $this->fetchAll("SHOW TABLES"); | ||
foreach ($tables as $table) { | ||
$tableName = $table[array_keys($table)[0]]; | ||
$this->execute("ALTER TABLE `{$tableName}` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters