Skip to content

A free open source IT asset/license management system

Fix migration from integer to string to handle polymorphic migration

snipe90af734f6bd6
diff --git a/database/migrations/2016_09_04_180400_create_actionlog_table.php b/database/migrations/2016_09_04_180400_create_actionlog_table.php
index 8d98552b02..c5c7c67af0 100644
--- a/database/migrations/2016_09_04_180400_create_actionlog_table.php
+++ b/database/migrations/2016_09_04_180400_create_actionlog_table.php
@@ -18,7 +18,7 @@ class CreateActionlogTable extends Migration
$table->integer('user_id')->nullable();
$table->string('action_type');
$table->integer('target_id')->nullable(); // Was checkedout_to
- $table->integer('target_type')->nullable(); // For polymorphic thingies
+ $table->string('target_type')->nullable(); // For polymorphic thingies
$table->integer('location_id')->nullable();
$table->text('note')->nullable();
$table->text('filename')->nullable();
diff --git a/database/migrations/2016_09_19_235935_fix_fieldtype_for_target_type.php b/database/migrations/2016_09_19_235935_fix_fieldtype_for_target_type.php
new file mode 100644
index 0000000000..db10820f60
--- /dev/null
+++ b/database/migrations/2016_09_19_235935_fix_fieldtype_for_target_type.php
@@ -0,0 +1,31 @@
+<?php
+
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Database\Migrations\Migration;
+
+class FixFieldtypeForTargetType extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::table('action_logs', function ($table) {
+ $table->string('target_type')->nullable()->default(null)->change();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('action_logs', function ($table) {
+ $table->integer('target_type')->nullable()->default(null)->change();
+ });
+ }
+}