Adds ID columns to tables that don’t have them - reproduces #9363

This reproduces #9363 without the PK in custom fields

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2021-04-14 15:07:11 -07:00
parent 2c0438bdcb
commit 39b0f464d2

View file

@ -0,0 +1,54 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddIdsToTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('migrations', function (Blueprint $table) {
// Add the id column to the migrations table if it doesn't yet have one
if (!Schema::hasColumn('migrations', 'id')) {
$table->increments('id');
}
});
Schema::table('password_resets', function (Blueprint $table) {
// Add the id column to the password_resets table if it doesn't yet have one
if (!Schema::hasColumn('password_resets', 'id')) {
$table->increments('id');
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('migrations', function (Blueprint $table) {
if (Schema::hasColumn('migrations', 'id')) {
$table->dropColumn('id');
}
});
Schema::table('password_resets', function (Blueprint $table) {
if (Schema::hasColumn('password_resets', 'id')) {
$table->dropColumn('id');
}
});
}
}