[Bug Report]: Primary keys required in MySQL 8 DB cluster #2487

Closed
opened 2026-02-05 04:18:23 +03:00 by OVERLORD · 1 comment
Owner

Originally created by @aqos156 on GitHub (Nov 11, 2021).

Describe the Bug

MySQL DB cluster requires having primary keys for row replication. These aren't present in certain migrations.

  Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. (SQL: create table `password_resets` (`email` varchar(191) not null, `token` varchar(191) not null, `created_at` timestamp not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'),
Migration table created successfully.,
    666|         // message to include the bindings with SQL, which will make this exception a,
Migrating: 2014_10_12_000000_create_users_table,
Migrated:  2014_10_12_000000_create_users_table (0.14 seconds),
Migrating: 2014_10_12_100000_create_password_resets_table,
  at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669,
      /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:119,
  Please use the argument -v to see more details.,
  2   Doctrine\DBAL\Driver\PDO\Exception::new(),
      /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18,
  1   Doctrine\DBAL\Driver\PDO\Exception::("SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting."),
  Exception trace:,
    673|,
    672|         },
    671|             );,
    670|                 $query, $this->prepareBindings($bindings), $e,
  > 669|             throw new QueryException(,
    668|         catch (Exception $e) {,
    667|         // lot more helpful to the developer instead of just the database's errors.,
    665|         // If an exception occurs when attempting to run a query, we'll format the error

Steps to Reproduce

  1. Create a MySQL DB cluster (on DigitalOcean even single instance has the required settings)
  2. Try to setup a instance of BookStack on the cluster

Expected Behaviour

To have primary keys in all tables during migrations, thus supporting MySQL 8 clustering.

Screenshots or Additional Context

No response

Exact BookStack Version

v21.10.03

PHP Version

No response

Hosting Environment

linuxserver.io docker image on debian and MySQL 8 DB cluster in DigitalOcean

Originally created by @aqos156 on GitHub (Nov 11, 2021). ### Describe the Bug MySQL DB cluster requires having primary keys for row replication. These aren't present in certain migrations. ``` Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting. (SQL: create table `password_resets` (`email` varchar(191) not null, `token` varchar(191) not null, `created_at` timestamp not null) default character set utf8mb4 collate 'utf8mb4_unicode_ci'), Migration table created successfully., 666| // message to include the bindings with SQL, which will make this exception a, Migrating: 2014_10_12_000000_create_users_table, Migrated: 2014_10_12_000000_create_users_table (0.14 seconds), Migrating: 2014_10_12_100000_create_password_resets_table, at /var/www/html/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669, /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:119, Please use the argument -v to see more details., 2 Doctrine\DBAL\Driver\PDO\Exception::new(), /var/www/html/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDO/Exception.php:18, 1 Doctrine\DBAL\Driver\PDO\Exception::("SQLSTATE[HY000]: General error: 3750 Unable to create or change a table without a primary key, when the system variable 'sql_require_primary_key' is set. Add a primary key to the table or unset this variable to avoid this message. Note that tables without a primary key can cause performance problems in row-based replication, so please consult your DBA before changing this setting."), Exception trace:, 673|, 672| }, 671| );, 670| $query, $this->prepareBindings($bindings), $e, > 669| throw new QueryException(, 668| catch (Exception $e) {, 667| // lot more helpful to the developer instead of just the database's errors., 665| // If an exception occurs when attempting to run a query, we'll format the error ``` ### Steps to Reproduce 1. Create a MySQL DB cluster (on DigitalOcean even single instance has the required settings) 2. Try to setup a instance of BookStack on the cluster ### Expected Behaviour To have primary keys in all tables during migrations, thus supporting MySQL 8 clustering. ### Screenshots or Additional Context _No response_ ### Exact BookStack Version v21.10.03 ### PHP Version _No response_ ### Hosting Environment linuxserver.io docker image on debian and MySQL 8 DB cluster in DigitalOcean
OVERLORD added the 🐛 Bug label 2026-02-05 04:18:23 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Nov 11, 2021):

Hi @aqos156,

This has previously been discussed here: https://github.com/BookStackApp/BookStack/issues/2612#issuecomment-791961113.

As per that thread, I don't really see this as a bug for this project since it's mostly down to the enforcement from a specific cloud vendor, or for a database feature we don't advertise to support. I'm not overly comfortable with the feature-set of specific vendors being the deciding factor in our efforts/support level. Looks like the framework we use did potentially look to make changes to support such environments but they were reverted due to bugs. Maybe something we could potentially support in the future but don't think we can easily support right now.

From what I've seen there looks like there are some workarounds or some people have managed to request the enforcement of primary keys be turned off in their environment. Otherwise will close this off.

@ssddanbrown commented on GitHub (Nov 11, 2021): Hi @aqos156, This has previously been discussed here: https://github.com/BookStackApp/BookStack/issues/2612#issuecomment-791961113. As per that thread, I don't really see this as a bug for this project since it's mostly down to the enforcement from a specific cloud vendor, or for a database feature we don't advertise to support. I'm not overly comfortable with the feature-set of specific vendors being the deciding factor in our efforts/support level. Looks like the framework we use did potentially look to make changes to support such environments but they were reverted due to bugs. Maybe something we could potentially support in the future but don't think we can easily support right now. From what I've seen there looks like there are some workarounds or some people have managed to request the enforcement of primary keys be turned off in their environment. Otherwise will close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2487