Back in time fix FOR #7145 for new installs on MySQL 8+

This commit is contained in:
snipe 2019-06-12 16:24:55 -07:00
parent 30904dd019
commit 2bfa05fd2d
2 changed files with 20 additions and 4 deletions

View file

@ -29,7 +29,7 @@ class MigrationCartalystSentryInstallGroups extends Migration {
*/
public function up()
{
Schema::create('groups', function($table)
Schema::create('permission_groups', function($table)
{
$table->increments('id');
$table->string('name');
@ -46,7 +46,7 @@ class MigrationCartalystSentryInstallGroups extends Migration {
*/
public function down()
{
Schema::drop('groups');
Schema::drop('permission_groups');
}
}

View file

@ -13,7 +13,21 @@ class RenameGroupsTable extends Migration
*/
public function up()
{
Schema::rename('groups', 'permission_groups');
// We check to see if this table exists before attempting the migration since
// upgraded installs would have this table, but new installs wouldn't.
// We had to change the name of the table in the older migrations
// to handle a MySQl 8+ compatibility issue related to reserved words.
// Without going back in time in migrations, this would fail since the groups table
// would never be allowed to be created in the first place on MySql 8+.
//
// So... if an upgrade, let's rename that table.
// If a new install, the migration was already changed, so the table isn't
// called that anymore and we can skip this migration.
if (Schema::hasTable('groups')) {
Schema::rename('groups', 'permission_groups');
}
}
/**
@ -23,6 +37,8 @@ class RenameGroupsTable extends Migration
*/
public function down()
{
Schema::rename('permission_groups', 'groups');
if (Schema::hasTable('permission_groups')) {
Schema::rename('permission_groups', 'groups');
}
}
}