|
@@ -0,0 +1,32 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
+
|
|
|
|
|
+return new class extends Migration
|
|
|
|
|
+{
|
|
|
|
|
+ public function up(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $columnsByTable = [
|
|
|
|
|
+ 'orders' => ['name', 'object_address', 'tg_group_name', 'tg_group_link'],
|
|
|
|
|
+ 'users' => ['name'],
|
|
|
|
|
+ 'districts' => ['shortname', 'name'],
|
|
|
|
|
+ 'areas' => ['name'],
|
|
|
|
|
+ 'object_types' => ['name'],
|
|
|
|
|
+ 'order_statuses' => ['name'],
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ foreach ($columnsByTable as $table => $columns) {
|
|
|
|
|
+ foreach ($columns as $column) {
|
|
|
|
|
+ DB::statement(
|
|
|
|
|
+ "UPDATE {$table} SET {$column} = TRIM({$column}) WHERE {$column} IS NOT NULL AND {$column} <> TRIM({$column})"
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function down(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ // Irreversible: trimmed whitespace cannot be restored.
|
|
|
|
|
+ }
|
|
|
|
|
+};
|