Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support table creation w/o primary key #33

Merged

Conversation

weotch
Copy link
Contributor

@weotch weotch commented Sep 14, 2021

This disables the sql_require_primary_key setting (which is enabled by default on DigitalOcean Managed Databases) in advance of table creation so that the createTable for the message table doesn't have a fatal error like this:

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.
The SQL being executed was: CREATE TABLE `message` (
  `id` int(11) NOT NULL,
  `dateCreated` datetime(0) NOT NULL,
  `dateUpdated` datetime(0) NOT NULL,
  `uid` char(36) NOT NULL DEFAULT '0',
  `language` varchar(16) NOT NULL,
  `translation` text
) CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB

This is similar to the Laravel workaround described here: laravel/framework#33238 (comment)

@smcyr
Copy link
Contributor

smcyr commented Sep 14, 2021

Looks good to me, thanks!

@smcyr smcyr merged commit 4ae0775 into MutationDigitale:master Sep 14, 2021
@weotch weotch deleted the feature/support-sql-require-primary-key branch September 14, 2021 18:37
@weotch weotch restored the feature/support-sql-require-primary-key branch September 14, 2021 18:37
@weotch weotch deleted the feature/support-sql-require-primary-key branch September 14, 2021 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants