Skip to content

Commit

Permalink
only add parent_id column if it doesn't exist (#8)
Browse files Browse the repository at this point in the history
* only add parent_id column if it doesn't exist

* Apply fixes from StyleCI

[ci skip] [skip ci]

* explanation

* Apply fixes from StyleCI

[ci skip] [skip ci]
  • Loading branch information
tomschlick authored Apr 18, 2019
1 parent d8c9ec4 commit 2db9f6f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions migrations/2018_09_04_161009_add_parent_id_to_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ class AddParentIdToTable extends Migration
public function up()
{
Schema::table(config('process-stamps.table'), function (Blueprint $table) {
$table->unsignedInteger('parent_id')->nullable()->index()->after('hash');

$table->foreign('parent_id')
->references(config('process-stamps.columns.primary_key'))
->on(config('process-stamps.table'));
// In v1.1.2 we changed the timestamp of this migration.
// This check prevents issues if someone already migrated with the old timestamp.
if (! Schema::hasColumn(config('process-stamps.table'), 'parent_id')) {
$table->unsignedInteger('parent_id')->nullable()->index()->after('hash');

$table->foreign('parent_id')
->references(config('process-stamps.columns.primary_key'))
->on(config('process-stamps.table'));
}
});
}

Expand Down

0 comments on commit 2db9f6f

Please sign in to comment.