Unable to install module in installation profile

Created on 30 March 2024, 8 months ago
Updated 9 April 2024, 8 months ago

Problem/Motivation

For easy reusability, I'm creating an installtion profile which includes this module. However, I'm running into an issue when attempting to perform a clean Drupal installation using said profile.

The error message is: Cannot add field 'key_value_expire.preview_token': table doesn't exist.

From my research, it looks like the problem lies in the new field "preview_token" that gets added when installing the module. On an existing installation, this works. However, the "key_value_expire" table that this installation hook depends on doesn't yet exist when installed Drupal for the first time.

Steps to reproduce

- Create a basic installation profile which includes this module in the "install" section
- Attempt to install Drupal using this installation profile

Proposed resolution

From the research I have done, I cannot find a straight-forward way to have the module "wait" until the table exists. What I would propose, is to not add a separate field to the "key_value_expire" table, but instead add the preview token as a separate entry in the table, with a reference to the entity being previewed.

I do understand that it will add extra database calls compared to the current solution, but I personally think that the reliability of this method will be worth it.

Remaining tasks

- Implement the proposed change
- Add an update hook to remove the field on existing installations
- Create a pull request

User interface changes

N/A

API changes

N/A

Data model changes

The "preview_token" field will no longer be present in the "key_value_expire" table, and will instead be a separate entry in the table

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇳🇱Netherlands Dobefu

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024