Upgrading fails because of a missing file_usage table. See error below.

System module

Update #7059

    * Failed: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'core.file_usage' doesn't exist: SELECT 1 AS expression FROM {file_usage} file_usage WHERE (fid = :db_condition_placeholder_0) AND (module = :db_condition_placeholder_1) AND (type = :db_condition_placeholder_2) AND (id IS NULL ) FOR UPDATE; Array ( [:db_condition_placeholder_0] => 4 [:db_condition_placeholder_1] => file [:db_condition_placeholder_2] => node ) in file_usage_add() (line 608 of /Users/erik/www/core/includes/file.inc).

If the database has been anonymized sufficiently I will upload it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sutharsan’s picture

Assigned: Unassigned » Sutharsan
catch’s picture

Issue tags: +D7 upgrade path
Sutharsan’s picture

Assigned: Sutharsan » Unassigned
Status: Active » Needs review
FileSize
3.6 KB

In system_update_7059() the {file_update} table is used while it is only created in system_update_7060().
This patch moves create table the code form system_update_7060() to system_update_7059().

Sutharsan’s picture

FileSize
277.53 KB

Attached database to reproduce this issue and #895088: Upgrade fails

clemens.tolboom’s picture

FileSize
4.09 KB

As system_update_7060 is now empty we need to adjust user_update_dependencies to point to system_update_7059

catch’s picture

Status: Needs review » Reviewed & tested by the community

Looks great.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Great! Committed to HEAD. Thanks!

pbuyle’s picture

Status: Fixed » Needs work
FileSize
1.02 KB

If the upload table does not exists on the upgraded site, the file_usage will not be created because of the check at the beginning of system_update_7059. Also, system_update_7059 can be run multiple times since it process batches of 500 files at a time. At the second run, an DatabaseSchemaObjectExistsException is thrown.

Here as patch to separate table creation and upload migration and avoid these issues.

pbuyle’s picture

Status: Needs work » Needs review
marvil07’s picture

This is needed for solving #895176: Upgrade fails because of integrity constraint violation in system_update_7060, and after testing it against the other issue(see the database at #895176-3: Upgrade fails because of integrity constraint violation in system_update_7060) we can get the real error mentioned in the mentioned issue.

webchick’s picture

Status: Needs review » Fixed

Marco discussed this with me in person, and said it's RTBC. So, committed to HEAD. :)

groovehunter’s picture

Got almost same error with current snapshot, after a while, playing with it and installing some mods, views, rdfx,...

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal_7a.file_usage' doesn't exist: SELECT f.module AS module, f.type AS type, f.id AS id, f.count AS count FROM {file_usage} f WHERE (fid = :db_condition_placeholder_0) AND (count > :db_condition_placeholder_1) ; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => 0 )  in file_usage_list() (line 571 of /var/www/drupal-7.x-dev/includes/file.inc).

update.php doesnt fix it.

groovehunter’s picture

just to note an error resulting from that

using rdfx / rdfui module and entering a RDF predicate for the voc on

http://drupal7/admin/structure/types/manage/page/fields/field_myvoc1

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: http://drupal7/rdfui/predicates/autocomplete
StatusText: OK
ResponseText: []PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'drupal_7.file_usage' doesn't exist: SELECT f.module AS module, f.type AS type, f.id AS id, f.count AS count
FROM 
{file_usage} f
WHERE  (fid = :db_condition_placeholder_0) AND (count > :db_condition_placeholder_1) ; Array
(
[:db_condition_placeholder_0] => 1
[:db_condition_placeholder_1] => 0
)
in file_usage_list() (line 571 of /var/www/drupal-7.x-dev/includes/file.inc).

groovehunter’s picture

just to get the table created i helped me by executing per web

module_load_include('install','system');
$sandbox=array();
system_update_7059(&$sandbox);

before i outcommented the check for existing update table

throws errors but at least the table is created and as my installation is fresh there are no uploads resp. files yet

David_Rothstein’s picture

Cross-linking this to its HEAD to HEAD issue, for those who care: #905776: #895032 - Update for creating the {file_usage} table

Status: Fixed » Closed (fixed)
Issue tags: -D7 upgrade path

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