feat: 统一表为utf8mb4_unicode_ci

This commit is contained in:
weifs 2024-02-20 15:00:38 +08:00
parent 82063f1b21
commit 192de79fea

View File

@ -0,0 +1,44 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\Schema;
class ChangeCharsetToUtf8mb4 extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$pre = DB::connection()->getTablePrefix();
$tables = [
"approve_execution",
"approve_execution_history",
"approve_identitylink",
"approve_identitylink_history",
"approve_proc_inst",
"approve_proc_inst_history",
"approve_proc_msgs",
"approve_procdef",
"approve_procdef_history",
"approve_task",
"approve_task_history"
];
foreach ($tables as $table) {
if (Schema::hasTable($table)) {
Schema::getConnection()->getPdo()->exec("ALTER TABLE `{$pre}{$table}` CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci");
}
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}