|
|
@@ -0,0 +1,26 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+use Illuminate\Database\Migrations\Migration;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
+
|
|
|
+/** sport_order.user_id 单独使用 utf8mb4_unicode_ci,与 users.user_id 关联时报 1267,统一为库默认排序规则。 */
|
|
|
+return new class extends Migration
|
|
|
+{
|
|
|
+ public function up(): void
|
|
|
+ {
|
|
|
+ $this->collate('utf8mb4_general_ci');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function down(): void
|
|
|
+ {
|
|
|
+ $this->collate('utf8mb4_unicode_ci');
|
|
|
+ }
|
|
|
+
|
|
|
+ private function collate(string $collation): void
|
|
|
+ {
|
|
|
+ $grammar = DB::connection()->getQueryGrammar();
|
|
|
+ DB::statement('ALTER TABLE ' . $grammar->wrapTable('sport_order')
|
|
|
+ . ' MODIFY ' . $grammar->wrap('user_id')
|
|
|
+ . " VARCHAR(20) CHARACTER SET utf8mb4 COLLATE {$collation} NOT NULL COMMENT '用户ID'");
|
|
|
+ }
|
|
|
+};
|