Running update.php fails for me after upgrading to the latest release of filebrowser with following message:

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42601]: Syntax error: 7 ERROR: syntax error at or near "USING" LINE 1: CREATE INDEX fid_module_name USING BTREE ON filebrowser_meta... ^: CREATE INDEX fid_module_name USING BTREE ON filebrowser_metadata_entity (fid, module, name); Array ( ) in filebrowser_update_9106()

I assume this is related to this update: https://www.drupal.org/project/filebrowser/issues/3361551

Versions:

  • Drupal: 10.4.7
  • PHP: 8.2.28
  • Database: PostgreSQL 15.13

Comments

vtrefny created an issue. See original summary.

clivesj’s picture

My bad!
I overlooked that that query does not run on PostgreSQL.
I am preparing a fix for this.

  • clivesj committed bbc6dc88 on 3.1.x
    Issue #3528234: Database update fails after upgrading to 3.1.5
    
clivesj’s picture

Status: Active » Fixed

I have released 3.1.6 that contains a fix for this.

Testing showed that on some Postgres, the update failed silently, not adding the index but at the same time marking update 9106 as completed. Others will fail and mark the update as non-completed.
I have to make sure all sites will receive the update to add the index and no site is stuck at update 9106.
To solve this and prevent the need to manually update the schema-version in the key-value table, I have chosen to re-write update 9106 to a no-op (empty) function. I know we are not supposed to change published install hooks, but I think in this case it is perfectly safe and always better than asking people to manually adjust the database.

lewih’s picture

Hello community!

I just updated from version 3.1.4 to 3.1.6.

By running drush updb I get the following error:

drush updb
 ------------- ----------- --------------- ------------------------------------ 
  Module        Update ID   Type            Description                         
 ------------- ----------- --------------- ------------------------------------ 
  filebrowser   9105        hook_update_n   9105 - Add uid (user id) base       
                                            field to                            
                                            filebrowser_metadata_entity         
                                            entity.                             
  filebrowser   9106        hook_update_n   9106 - filebrowser_update_9106():   
                                            No-op. This is a re-write.          
                                            Previous version did not work for   
                                            Postgres. On some installations     
                                            the update failed silently and      
                                            marked 9106 as completed, others    
                                            failed and did not complete 9106.   
                                            To prevent users to have to         
                                            manually update the database we     
                                            have chosen to rewrite 9106 to      
                                            make sure all installations create  
                                            the index.  - Sites with schema <   
                                            9106 will still mark 9106 done      
                                            (even though no work happens        
                                            here).  - Sites with schema = 9106  
                                            (the “ghost-done” PG16 case)        
                                            will skip straight over it.         
  filebrowser   9107        hook_update_n   9107 - filebrowser_update_9107():   
                                            Ensure fid_module_name exists.      
                                            This hook will run on _every_ site  
                                            that now needs the index:  - Sites  
                                            that just marked 9106 done here     
                                            (schema was <9106) will hit 9107.   
                                            - Sites that skipped 9106 because   
                                            they were already at schema=9106    
                                            will also hit 9107.  - Sites on     
                                            MySQL that already have the index   
                                            will see it and do nothing.         
 ------------- ----------- --------------- ------------------------------------ 


 ┌ Do you wish to run the specified pending updates? ───────────┐
 │ Yes                                                          │
 └──────────────────────────────────────────────────────────────┘

>  [notice] Update started: filebrowser_update_9105
>  [notice] Installed 'user_id' field on filebrowser_metadata_entity entity.
>  [notice] Update completed: filebrowser_update_9105
>  [notice] Update started: filebrowser_update_9106
>  [notice] Update completed: filebrowser_update_9106
>  [notice] Update started: filebrowser_update_9107
>  [error]  MySQL needs the 'fid' field specification in order to normalize the 'fid_module_name' index 
>  [error]  Update failed: filebrowser_update_9107 
 [error]  Update aborted by: filebrowser_update_9107 
 [error]  Finished performing updates. 

On update.php I have:

Update #9107

Failed: Drupal\Core\Database\SchemaException: MySQL needs the 'fid' field specification in order to normalize the 'fid_module_name' index in Drupal\mysql\Driver\Database\mysql\Schema->getNormalizedIndexes() (line 329 of /mywebsite/web/core/modules/mysql/src/Driver/Database/mysql/Schema.php).

I am running:
mysql Ver 8.0.41-0ubuntu0.24.04.1 for Linux on x86_64 ((Ubuntu))
Drupal 10.5.0.
PHP 8.3.20

May the error be related to this issue ?

Thanks in advance!

Best,
MP

clivesj’s picture

Unfortunately there is still a bug in the update script.
I will fix the issue here:
https://www.drupal.org/project/filebrowser/issues/3531198

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.