Ensure column does not exist before creation

This commit is contained in:
Josef Citrine 2016-09-22 23:28:24 +01:00
parent abdfe2f698
commit 66ffd7714d

View file

@ -30,7 +30,8 @@ class AddDeletedAtColumnToActivities extends Migration
*/
public function up()
{
Schema::table('activities', function(Blueprint $table) {
if (!Schema::hasColumn('activities', 'deleted_at')) {
Schema::table('activities', function (Blueprint $table) {
$table->softDeletes()->index();
});
@ -63,6 +64,7 @@ class AddDeletedAtColumnToActivities extends Migration
->whereNotNull('comments.deleted_at')
->update(['deleted_at' => DB::raw('comments.deleted_at')]);
}
}
/**
* Reverse the migrations.