Use composer scripts to automate schema update

Created on 28 June 2023, over 1 year ago

Problem/Motivation

Recently, I encounter a login issue after updating Drupal from 10.0 to 10.1. https://www.drupal.org/project/drupal/issues/3370483 πŸ’¬ Login broken after updating to Drupal 10.1 Closed: works as designed
The solution was to manually run update after running a composer update command.

Although I have been using Drupal for a while, I have not been running the update script and, luckily, not encountered an issue until now.

For new developers (and forgetful ones), it may not be immediately obvious this is required.

Proposed resolution

Composer supports various command event scripts that act similar to hooks for common commands.

Using this, we can automate scripts _after_ developers run composer update.
Something similar to:

    "scripts": {
        "post-update-cmd": [
            "drush updb -y"
        ]
    },

The above example (assumes Drush exists and) automates a database update but it could easier be replaced with a custom script that does whatever we require.

Perhap there is a technical reason Drupal does not already do this.

✨ Feature request
Status

Closed: duplicate

Version

11.0 πŸ”₯

Component
Database updateΒ  β†’

Last updated 1 day ago

No maintainer
Created by

πŸ‡―πŸ‡΅Japan tyler36 Osaka

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

Comments & Activities

  • Issue created by @tyler36
  • I don’t think it is possible to assume Drush exists, or even that every site would want this. I am voting β€œno” for this feature in this form.

    Every site’s Composer configuration is customized so anyone is free to add this if they wish.

  • πŸ‡―πŸ‡΅Japan tyler36 Osaka

    My original post contained an example script, as stated. It was not intended to be included as-is. Many sites do not use or need drush.

    The request is to automate a manually step which helps improve the developer experience.

    The current experience:
    - composer update
    - Login to site
    - Visit '/admin/reports'
    - Click "status report"
    - Scroll down to check for Database updates
    - If exists, click `update`

    A suggested solution is to use composer's command event scripts.

    Suggested experience:
    - composer update

  • Status changed to Closed: duplicate over 1 year ago
  • πŸ‡¬πŸ‡§United Kingdom longwave UK

    As @cilefen says there is no one size fits all here; you are free to add such a command to your composer.json but this will not work for everyone in all environments. We have a full set of documentation on updating Drupal as there are many options: https://www.drupal.org/docs/updating-drupal β†’ - please refer to this to figure out which is the best way for your setup.

    The Automatic Updates initiative hopes to eventually solve this in a better way for some users, closing as duplicate.

Production build 0.71.5 2024