Skip to content

A free open source IT asset/license management system

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

snipe2bfa05fd2d9b
diff --git a/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php b/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php
index 034a6a16d8..d929a62707 100644
--- a/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php
+++ b/database/migrations/2012_12_06_225929_migration_cartalyst_sentry_install_groups.php
@@ -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');
}
}
diff --git a/database/migrations/2019_06_12_184327_rename_groups_table.php b/database/migrations/2019_06_12_184327_rename_groups_table.php
index 011570579f..3c50971614 100644
--- a/database/migrations/2019_06_12_184327_rename_groups_table.php
+++ b/database/migrations/2019_06_12_184327_rename_groups_table.php
@@ -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');
+ }
}
}