Failed: Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[55000]:

Created on 16 December 2023, 6 months ago
Updated 13 March 2024, 3 months ago

Hello and thanks for your efforts for the 10.2.0 version.

Problem/Motivation

I've tried to update my 10.1.7 installation, which is running with PostgreSQL 15.5, to 10.2.0 version and when I try to run database update script, I get the error below:

system module
Update #10101

    Failed: Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR: sequence must have same owner as table it is linked to: CREATE SEQUENCE batch_bid_seq OWNED BY "batch"."bid"; Array ( ) in system_update_10101() (line 1859 of /var/www/html/web/core/modules/system/system.install).

I've also tried changing the owner of the database, but it doesn't work either.

Steps to reproduce

- ddev composer update "drupal/core-*" --with-all-dependencies
- ddev drush updb

>  [notice] Update started: system_update_10101
>  [error]  SQLSTATE[55000]: Object not in prerequisite state: 7 ERROR:  sequence must have same owner as table it is linked to: CREATE SEQUENCE batch_bid_seq OWNED BY "batch"."bid"; Array
> (
> )
>  
>  [error]  Update failed: system_update_10101

What can be the solution?

Best,
Orkut

🐛 Bug report
Status

Closed: works as designed

Version

10.2

Component
PostgreSQL driver 

Last updated 2 days ago

No maintainer
Created by

🇹🇷Turkey Orkut Murat Yılmaz

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

Comments & Activities

  • Issue created by @Orkut Murat Yılmaz
  • 🇹🇷Turkey Orkut Murat Yılmaz

    thank you @andypost for correcting the issue tag and adding the related issues.

  • Status changed to Closed: works as designed 6 months ago
  • 🇹🇷Turkey Orkut Murat Yılmaz

    sorry, I'm switching to DDEV from docker4drupal and I was confused about my environments. I've changed my DDEV's PostgreSQL config and the problem disappeared.

    thanks for everything. I'm closing the issue.

  • 🇫🇷France planceleur

    Hi Orkut Murat Yilmaz,
    I have exactly the same problem and cannot resolve it. Could you be more explicit on the change you made in the DDEV PostgreSQL config ?
    I am currently using postgres:14 (apparently the only version that works with DDEV). Did you go to mysql to fix this issue?
    Many thanks for any help, I am stucked with this!
    Philippe

  • 🇹🇷Turkey Orkut Murat Yılmaz

    @planceleur, sorry for the late reply.

    Yes, I was enlightened like you did and solved my problem with changing the settings.ddev.php file parameters. Thank you for making me feel not alone:)

  • I am using lando what changes should i make @Orkut Murat Yılmaz

  • 🇹🇷Turkey Orkut Murat Yılmaz

    @neelam_wadhwani have you checked lando's postgres config?

  • 🇳🇴Norway vegardjo

    I had the same issue, and solved it with changing the owner in the database. First access the container with ddev ssh, then use psql to run the following:

    DO $$DECLARE r RECORD;
    BEGIN
        FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = 'public') LOOP
            EXECUTE 'ALTER TABLE IF EXISTS public.' || quote_ident(r.tablename) || ' OWNER TO db';
        END LOOP;
    END$$;
    

    I also ran this for sequences, but didn't test first if it was actually needed:

    DO $$DECLARE r RECORD;
    BEGIN
        FOR r IN (SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = 'public') LOOP
            EXECUTE 'ALTER SEQUENCE public.' || quote_ident(r.sequence_name) || ' OWNER TO db';
        END LOOP;
    END$$;
    

    Note: this worked for me, by help of chatGPT. It is not an area I know deeply, so do backup first and use at own risk!

Production build 0.69.0 2024