Database Issue on Upgrade to v0.30 #1855

Closed
opened 2026-02-05 02:03:42 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @swizzle1 on GitHub (Sep 21, 2020).

The following error came up at the end of upgrading from v0.29.3 to v0.30:

Migrating: 2020_08_04_111754_drop_joint_permissions_id

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table joint_permissions add primary key joint_primary(role_id, entity_type, entity_id, action))

at /home/ino1jdl5c9we/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {

669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|

Exception trace:

1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes")
/home/ino1jdl5c9we/BookStack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:131

2 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes")
/home/ino1jdl5c9we/BookStack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:129

Please use the argument -v to see more details.

Originally created by @swizzle1 on GitHub (Sep 21, 2020). The following error came up at the end of upgrading from v0.29.3 to v0.30: Migrating: 2020_08_04_111754_drop_joint_permissions_id Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `joint_permissions` add primary key `joint_primary`(`role_id`, `entity_type`, `entity_id`, `action`)) at /home/ino1jdl5c9we/BookStack/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669 665| // If an exception occurs when attempting to run a query, we'll format the error 666| // message to include the bindings with SQL, which will make this exception a 667| // lot more helpful to the developer instead of just the database's errors. 668| catch (Exception $e) { > 669| throw new QueryException( 670| $query, $this->prepareBindings($bindings), $e 671| ); 672| } 673| Exception trace: 1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes") /home/ino1jdl5c9we/BookStack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:131 2 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes") /home/ino1jdl5c9we/BookStack/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:129 Please use the argument -v to see more details.
Author
Owner

@ssddanbrown commented on GitHub (Sep 22, 2020):

Hi @swizzle1,
Can you provide any details regarding your database at all?

Ideally it would be great to know the MySQL or MariaDB version in use and the table engine. Table engine can be found by running show table status like 'joint_permissions' on the bookstack database. Would also be ideal to know the Row Format on that table (Also shown by that command)

@ssddanbrown commented on GitHub (Sep 22, 2020): Hi @swizzle1, Can you provide any details regarding your database at all? Ideally it would be great to know the MySQL or MariaDB version in use and the table engine. Table engine can be found by running `show table status like 'joint_permissions'` on the bookstack database. Would also be ideal to know the Row Format on that table (Also shown by that command)
Author
Owner

@vlude commented on GitHub (Sep 22, 2020):

Hi Dan,
I am experiencing the same issue:
Migrating: 2020_08_04_111754_drop_joint_permissions_id

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table joint_permissions add primary key joint_primary(role_id, entity_type, entity_id, action))

at /home/vlude/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {

669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|

Exception trace:

1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes")
/home/vlude/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:131

2 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes")
/home/vlude/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:129

By running the above mentioned command on the bookstack DB:
image

DB version: 10.4.13-MariaDB - MariaDB Server

@vlude commented on GitHub (Sep 22, 2020): Hi Dan, I am experiencing the same issue: Migrating: 2020_08_04_111754_drop_joint_permissions_id Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes (SQL: alter table `joint_permissions` add primary key `joint_primary`(`role_id`, `entity_type`, `entity_id`, `action`)) at /home/vlude/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669 665| // If an exception occurs when attempting to run a query, we'll format the error 666| // message to include the bindings with SQL, which will make this exception a 667| // lot more helpful to the developer instead of just the database's errors. 668| catch (Exception $e) { > 669| throw new QueryException( 670| $query, $this->prepareBindings($bindings), $e 671| ); 672| } 673| Exception trace: 1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes") /home/vlude/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:131 2 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes") /home/vlude/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:129 By running the above mentioned command on the bookstack DB: ![image](https://user-images.githubusercontent.com/12392970/93852245-fb13a100-fcb1-11ea-8b24-02b6f02d5bff.png) DB version: 10.4.13-MariaDB - MariaDB Server
Author
Owner

@swizzle1 commented on GitHub (Sep 22, 2020):

Hi @swizzle1,
Can you provide any details regarding your database at all?

Ideally it would be great to know the MySQL or MariaDB version in use and the table engine. Table engine can be found by running show table status like 'joint_permissions' on the bookstack database. Would also be ideal to know the Row Format on that table (Also shown by that command)

I'm running MySQL v5.6.49-cll-lve. The engine is MyISAM. The row format is Dynamic.

@swizzle1 commented on GitHub (Sep 22, 2020): > Hi @swizzle1, > Can you provide any details regarding your database at all? > > Ideally it would be great to know the MySQL or MariaDB version in use and the table engine. Table engine can be found by running `show table status like 'joint_permissions'` on the bookstack database. Would also be ideal to know the Row Format on that table (Also shown by that command) I'm running MySQL v5.6.49-cll-lve. The engine is MyISAM. The row format is Dynamic.
Author
Owner

@philjak commented on GitHub (Sep 23, 2020):

InnoDB will fix this

@philjak commented on GitHub (Sep 23, 2020): InnoDB will fix this
Author
Owner

@ssddanbrown commented on GitHub (Sep 26, 2020):

I don't really know if it's worthwhile trying to change this database migration for this case at this stage. I think this will mainly show up where 'MyISAM' is used.

With MyISAM slowly fading out of usage I'd suggest upgrading the relevant table to InnoDB instead as suggested by @philjak above. This can be done, for the table in question, like so:

ALTER TABLE joint_permissions ENGINE=InnoDB;

Let me know if there are any issues encountered in doing this or if there any strong reasons why we might need to find an in-app strategy to fix.

@ssddanbrown commented on GitHub (Sep 26, 2020): I don't really know if it's worthwhile trying to change this database migration for this case at this stage. I think this will mainly show up where 'MyISAM' is used. With MyISAM slowly fading out of usage I'd suggest upgrading the relevant table to InnoDB instead as suggested by @philjak above. This can be done, for the table in question, like so: ```sql ALTER TABLE joint_permissions ENGINE=InnoDB; ``` Let me know if there are any issues encountered in doing this or if there any strong reasons why we might need to find an in-app strategy to fix.
Author
Owner

@swizzle1 commented on GitHub (Sep 26, 2020):

Ok, thank you. I changed it to InnoDB and will see if there are any other issues in the future.

@swizzle1 commented on GitHub (Sep 26, 2020): Ok, thank you. I changed it to InnoDB and will see if there are any other issues in the future.
Author
Owner

@vlude commented on GitHub (Oct 6, 2020):

Currently I am experiencing a different error, during php artisan migrate.
Version is .30.2
Migrating: 2020_08_04_111754_drop_joint_permissions_id

Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP COLUMN id; check that it exists (SQL: alter table joint_permissions drop id)

at /home/vlude/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {

669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|

Exception trace:

1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP COLUMN id; check that it exists")
/home/vlude/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:131

2 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP COLUMN id; check that it exists")
/home/vlude/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:129

@vlude commented on GitHub (Oct 6, 2020): Currently I am experiencing a different error, during php artisan migrate. Version is .30.2 Migrating: 2020_08_04_111754_drop_joint_permissions_id Illuminate\Database\QueryException : SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP COLUMN `id`; check that it exists (SQL: alter table `joint_permissions` drop `id`) at /home/vlude/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669 665| // If an exception occurs when attempting to run a query, we'll format the error 666| // message to include the bindings with SQL, which will make this exception a 667| // lot more helpful to the developer instead of just the database's errors. 668| catch (Exception $e) { > 669| throw new QueryException( 670| $query, $this->prepareBindings($bindings), $e 671| ); 672| } 673| Exception trace: 1 Doctrine\DBAL\Driver\PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP COLUMN `id`; check that it exists") /home/vlude/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:131 2 PDOException::("SQLSTATE[42000]: Syntax error or access violation: 1091 Can't DROP COLUMN `id`; check that it exists") /home/vlude/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:129
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1855