fix description
This commit is contained in:
+8
-3
@@ -13,9 +13,14 @@ return new class extends Migration
|
||||
public function up(): void
|
||||
{
|
||||
if (Schema::hasTable('products') && ! Schema::hasColumn('products', 'description')) {
|
||||
Schema::table('products', function ($table) {
|
||||
$table->text('description')->nullable();
|
||||
});
|
||||
// charset صریح — روی سرورهای latin1-default، TEXT بدون charset فارسی را نمیپذیرد
|
||||
DB::statement(
|
||||
'ALTER TABLE `products` ADD COLUMN `description` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL'
|
||||
);
|
||||
} elseif (Schema::hasTable('products') && Schema::hasColumn('products', 'description')) {
|
||||
DB::statement(
|
||||
'ALTER TABLE `products` MODIFY COLUMN `description` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL'
|
||||
);
|
||||
}
|
||||
|
||||
if (! Schema::hasTable('settings')) {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* روی بعضی سرورها (DB default = latin1) ستون description بدون charset اضافه شده
|
||||
* و ذخیرهٔ فارسی با خطای 3988 میخورد.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if (! Schema::hasTable('products') || ! Schema::hasColumn('products', 'description')) {
|
||||
return;
|
||||
}
|
||||
|
||||
DB::statement(
|
||||
'ALTER TABLE `products` MODIFY COLUMN `description` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL'
|
||||
);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
// عمداً به latin1 برنمیگردیم
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user