Help users that did not upgrade MySQL try two (#12989)

This commit is contained in:
Tony Murray
2021-07-14 08:39:41 -05:00
committed by GitHub
parent 4f7c7b3f2a
commit 1267f78de8

View File

@@ -12,16 +12,24 @@ class CreatePortGroupsTable extends Migration
*/
public function up()
{
// drop table if exists, migration can fail when creating index.
// migration can fail when creating index if the user's SQL server isn't new enough.
if (Schema::hasTable('port_groups')) {
Schema::drop('port_groups');
}
$table = Schema::getConnection()->getDoctrineSchemaManager()
->listTableDetails('port_groups');
Schema::create('port_groups', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->string('desc')->nullable();
});
// if the table exists and the index doesn't, add the index.
if (! $table->hasIndex('port_groups_name_unique')) {
Schema::table('port_groups', function (Blueprint $table) {
$table->unique('name');
});
}
} else {
Schema::create('port_groups', function (Blueprint $table) {
$table->increments('id');
$table->string('name')->unique();
$table->string('desc')->nullable();
});
}
}
/**