Problem/Motivation

Updated from 7x-2.10 to 7x-2.11 on php 5.3. When running drush updb, I get the following message:

Date  7006  Add date value indexes to existed field tables.       
 Date  7007  Update datestamp field schema to use 'big' integers.  
 Date  7200  The date_migrate_example module was renamed.
Do you wish to run all pending updates? (y/n):

I say yes, and it outputs:

SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'field_time_value' doesn't exist in table              [error]
Performed update: date_update_7006
Finished performing updates. 

When I run drush updb again, it gives me the list of three pending updates again, as if they had never been run.

Any thoughts?

Comments

ed2908 created an issue. See original summary.

damienmckenna’s picture

Version: 7.x-2.11 » 7.x-3.x-dev
Issue tags: +Needs tests

Due to the amount of changes needed for the all-day fix, 7.x-2.12 has been changed to 7.x-3.0.

damienmckenna’s picture

Version: 7.x-3.x-dev » 7.x-2.x-dev

Can you please test the current 7.x-2.x dev snapshot, let us know if it solves the problems or if they still exist. Thank you.

damienmckenna’s picture

Title: Database updates not applied on drush updb when upgrading from 7x-2.10 to 7x-2.11 » date_update_7006() can fail in certain circumstances

I'm starting to understand what happened. Can you please provide a list of columns in that table, and details of the field, that will help us track down the problem. Thank you.

micnap’s picture

I am running into this on a D7 site trying to update from 2.9 to 2.12. It's being caused by a field being only partially deleted. The field is listed in field_config (though not field_config_instance). It has a corresponding field_deleted_data_XXX and field_deleted_revision_XXX. But no amount of field_delete_field, field_purge_batch([ridiculously_high_number]) and cron runs is cleaning things up. There are also half a dozen other partially deleted fields on this site. Haven't worked out why yet. But that's the cause of this issue with running update 7006 for me.

ed2908’s picture

Hi Damien,

I'm sorry I somehow missed your last reply. I'll test with the snapshot and see what happens next week. I'll also check for partially deleted fields just in case it's that.

-Evan

ed2908’s picture

Sorry for the slow reply. I only just got the chance to take another look at this.

The columns of field_config look like this:

id
field_name
type
module
active
storage_type
storage_module
storage_active
locked
data
cardinality
translatable
deleted

field_time_value isn't among the listed fields.

I don't see it in field_config_instance either.

Doing a search across all tables in the database, using exact phrase for "field_time_value" returns 0 results.
Doing a search across all code in the website, I don't see any reference to this field.

As a test, I created a new field called field_time_value using the date type. When I search SQL now, I find my new field in both tables. The error preventing the update persists though. Same message of how it can't find that key column.

I reset my database, then tried investigating deleted data tables.

I ran:

drush eval "field_purge_batch(500)"

and got some relevant errors:

WD php: PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_time0.entity_type' in 'field list': SELECT                      [error]
field_data_field_time0.entity_type AS entity_type, field_data_field_time0.entity_id AS entity_id, field_data_field_time0.revision_id AS revision_id,
field_data_field_time0.bundle AS bundle
FROM 
{field_data_field_time} field_data_field_time0
WHERE  (field_data_field_time0.deleted = :db_condition_placeholder_0) AND (field_data_field_time0.bundle = :db_condition_placeholder_1) AND(( ( EXISTS  (SELECT
na.nid AS nid
FROM 
{node_access} na
WHERE (( (na.gid IN  (:db_condition_placeholder_2)) AND (na.realm = :db_condition_placeholder_3) ))AND (na.grant_view >= :db_condition_placeholder_4) AND
(field_data_field_time0.entity_id = na.nid) )) AND (field_data_field_time0.entity_type = :db_condition_placeholder_5) )OR (field_data_field_time0.entity_type 
:db_condition_placeholder_6) )
LIMIT 500 OFFSET 0; Array
(
    [:db_condition_placeholder_0] => 1
    [:db_condition_placeholder_1] => field_activity
    [:db_condition_placeholder_2] => 0
    [:db_condition_placeholder_3] => all
    [:db_condition_placeholder_4] => 1
    [:db_condition_placeholder_5] => node
    [:db_condition_placeholder_6] => node
)
 in field_sql_storage_field_storage_query() (line 748 of /vagrant_nfs/website/modules/field/modules/field_sql_storage/field_sql_storage.module).
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'field_data_field_time0.entity_type' in 'field list': SELECT field_data_field_time0.entity_type AS entity_type, field_data_field_time0.entity_id AS entity_id, field_data_field_time0.revision_id AS revision_id, field_data_field_time0.bundle AS bundle
FROM 
{field_data_field_time} field_data_field_time0
WHERE  (field_data_field_time0.deleted = :db_condition_placeholder_0) AND (field_data_field_time0.bundle = :db_condition_placeholder_1) AND(( ( EXISTS  (SELECT na.nid AS nid
FROM 
{node_access} na
WHERE (( (na.gid IN  (:db_condition_placeholder_2)) AND (na.realm = :db_condition_placeholder_3) ))AND (na.grant_view >= :db_condition_placeholder_4) AND (field_data_field_time0.entity_id = na.nid) )) AND (field_data_field_time0.entity_type = :db_condition_placeholder_5) )OR (field_data_field_time0.entity_type <> :db_condition_placeholder_6) )
LIMIT 500 OFFSET 0; Array
(
    [:db_condition_placeholder_0] => 1
    [:db_condition_placeholder_1] => field_activity
    [:db_condition_placeholder_2] => 0
    [:db_condition_placeholder_3] => all
    [:db_condition_placeholder_4] => 1
    [:db_condition_placeholder_5] => node
    [:db_condition_placeholder_6] => node
)
 in field_sql_storage_field_storage_query() (line 748 of /vagrant_nfs/website/modules/field/modules/field_sql_storage/field_sql_storage.module).
Drush command terminated abnormally due to an unrecoverable error. 

Similar result from drush ev "field_purge_batch(1000)"

Unsure how to proceed if Drush hits this error and cleans nothing. No idea why the date module is even looking at this missing field as it's not in the table that's being targeted for update.

ed2908’s picture

I tried the latest dev snapshot, no luck. The issue persists.

ed2908’s picture

As it happens, my SQL-fu was bad.

Searching for %field_time_value% did return a listing in field_config as described in #5. Deleted this as a test, and the updates processed properly.

Going to do some testing now to make sure none of my nodes or fields are broken or missing, but after deleting that instance, drush ev field purge batch works again.

ed2908’s picture

Status: Active » Fixed
damienmckenna’s picture

Issue tags: -Needs tests

Thanks for letting us know you were able to fix it.

Status: Fixed » Closed (fixed)

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