From 90af734f6bd6f2e54e485235f7c368dbdf2615f9 Mon Sep 17 00:00:00 2001 From: snipe Date: Tue, 20 Sep 2016 00:46:14 -0700 Subject: [PATCH] Fix migration from integer to string to handle polymorphic migration --- ...16_09_04_180400_create_actionlog_table.php | 2 +- ...9_235935_fix_fieldtype_for_target_type.php | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2016_09_19_235935_fix_fieldtype_for_target_type.php 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 @@ +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(); + }); + } +}