Skip to content

A free open source IT asset/license management system

Add migration to fix already escaped formats in the database

Ivan Nieto Vivanco99122ccb50da
diff --git a/database/migrations/2023_02_12_224353_fix_unescaped_customfields_format.php b/database/migrations/2023_02_12_224353_fix_unescaped_customfields_format.php
new file mode 100644
index 0000000000..f1779e996a
--- /dev/null
+++ b/database/migrations/2023_02_12_224353_fix_unescaped_customfields_format.php
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Models\CustomField;
+
+class FixUnescapedCustomfieldsFormat extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ $customfields = CustomField::where('format', 'LIKE', '%&%')->get();
+
+ foreach($customfields as $customfield){
+ $customfield->update(['format' => html_entity_decode($customfield->format)]);
+ }
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ //
+ }
+}