Skip to content

Commit

Permalink
Change activity log morph size to bigint.
Browse files Browse the repository at this point in the history
  • Loading branch information
haringsrob committed Apr 8, 2022
1 parent 9535d82 commit be43d41
Showing 1 changed file with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class UpdateActivityLogMorphSize extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$connection = Schema::connection(config('activitylog.database_connection'));
$tableName = config('activitylog.table_name');

if ($connection->hasTable($tableName)) {
$connection->table(
$tableName,
function (Blueprint $table) use ($connection, $tableName) {
if ($connection->hasColumn($tableName, 'subject_id')) {
$table->bigInteger('subject_id')->change();
}

if ($connection->hasColumn($tableName, 'causer_id')) {
$table->bigInteger('causer_id')->change();
}
}
);
}
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$connection = Schema::connection(config('activitylog.database_connection'));
$tableName = config('activitylog.table_name');

if ($connection->hasTable($tableName)) {
$connection->table(
$tableName,
function (Blueprint $table) use ($connection, $tableName) {
if ($connection->hasColumn($tableName, 'subject_id')) {
$table->integer('subject_id')->change();
}

if ($connection->hasColumn($tableName, 'causer_id')) {
$table->integer('causer_id')->change();
}
}
);
}
}
}

0 comments on commit be43d41

Please sign in to comment.