photos_access_user missing primary key

Created on 14 September 2023, 10 months ago
Updated 25 September 2023, 9 months ago

Problem/Motivation

Following installation of this package, drupal complained about transaction isolation level, and in particular that table photos_access_user did not have a primary key.

This was on a fresh install of drupal 10.1.3, and the package was installed using "composer require 'drupal/photos:^6.0'".
Database was 10.6.12-MariaDB-0ubuntu0.22.04.1
System was Ubuntu 22.04.3 LTS

Steps to reproduce

Issue is easily seen by querying the database:

MariaDB [drupaldb]> describe photos_access_user;
+-------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------------+------+-----+---------+-------+
| id | int(10) unsigned | NO | | NULL | |
| uid | int(10) unsigned | NO | MUL | NULL | |
| collaborate | tinyint(4) | YES | | 0 | |
+-------------+------------------+------+-----+---------+-------+

Note that no primary key is indicated.

Proposed resolution

Set the primary key:

MariaDB [drupaldb]> alter table photos_access_user modify column id int(10) unsigned PRIMARY KEY;
Query OK, 0 rows affected (0.049 sec)
Records: 0 Duplicates: 0 Warnings: 0

MariaDB [drupaldb]> describe photos_access_user;
+-------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------------+------+-----+---------+-------+
| id | int(10) unsigned | NO | PRI | NULL | |
| uid | int(10) unsigned | NO | MUL | NULL | |
| collaborate | tinyint(4) | YES | | 0 | |
+-------------+------------------+------+-----+---------+-------+

However it may also be necessary to set the field to auto_increment. I have not checked this.

Remaining tasks

I fixed this manually in my database. Change probably needs to go into the package.

User interface changes

None

API changes

None.

Data model changes

alter table photos_access_user to set column "id" to PRIMARY KEY, and possibly also to auto_increment.

🐛 Bug report
Status

Fixed

Version

6.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024