Skip to content

A free open source IT asset/license management system

Migration to drop stored_eula_column

snipebcd067121370
diff --git a/database/migrations/2022_05_16_235350_remove_stored_eula_field.php b/database/migrations/2022_05_16_235350_remove_stored_eula_field.php
new file mode 100644
index 0000000000..48c8a18825
--- /dev/null
+++ b/database/migrations/2022_05_16_235350_remove_stored_eula_field.php
@@ -0,0 +1,48 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+use App\Models\Actionlog;
+
+class RemoveStoredEulaField extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+
+ $actionlog_eulas = Actionlog::whereNotNull('stored_eula_file')->get();
+
+ foreach ($actionlog_eulas as $eula_file) {
+ $eula_file->filename = $eula_file->stored_eula_file;
+ $eula_file->save();
+ }
+
+ $actionlog_bad_action_type = Actionlog::where('item_id', '=', 0)->whereNull('target_type')->whereNull('action_type')->whereNull('target_type')->get();
+
+ foreach ($actionlog_bad_action_type as $bad_action_type) {
+ $bad_action_type->delete();
+ }
+
+ Schema::table('action_logs', function (Blueprint $table) {
+ $table->dropColumn('stored_eula_file');
+ });
+
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('action_logs', function (Blueprint $table) {
+ $table->string('stored_eula_file')->nullable()->default(null);
+ });
+ }
+}