Skip to content

Instantly share code, notes, and snippets.

@aaronschachter
Last active August 29, 2015 13:56
Show Gist options
  • Save aaronschachter/9291760 to your computer and use it in GitHub Desktop.
Save aaronschachter/9291760 to your computer and use it in GitHub Desktop.
Partners funtime
Deleted field_partners field
Cleared cache
SELECT *
FROM field_collection_item
WHERE field_name='field_partners'
52 rows
SELECT * FROM field_collection_item_revision rev
JOIN field_collection_item item on item.item_id = rev.item_id
WHERE field_name='field_partners'
142 rows
SELECT * FROM field_config
WHERE field_name='field_partners'
2 rows
SELECT * FROM field_config_instance
WHERE field_name='field_partners'
2 rows
Doing features-revert with dosomething_campaign and dosomething_taxonomy with missing field_partners stuff.
After features-revert, all queries return the same # of results.
DELETE FROM field_config
WHERE field_name='field_partners';
2 rows deleted
DELETE FROM field_config_instance
WHERE field_name='field_partners';
2 rows deleted
drush cc all
DELETE FROM
field_collection_item_revision
WHERE item_id IN (
SELECT item_id FROM field_collection_item WHERE field_name='field_partners'
)
142 rows deleted
DELETE FROM
field_collection_item
WHERE field_name = 'field_partners'
52 rows deleted
drush cc all
Warning: Unknown: GC cache entry '/vagrant/html/modules/file/file.install' (dev=21 ino=40985) was on gc-list for 3871 seconds in Unknown on line 0 Warning: Unknown: GC cache entry '/vagrant/html/modules/image/image.install' (dev=21 ino=69196) was on gc-list for 3871 seconds in Unknown on line 0 Warning: Unknown: GC cache entry '/vagrant/html/modules/taxonomy/taxonomy.install' (dev=21 ino=69161) was on gc-list for 3871 seconds in Unknown on line 0 Warning: Unknown: GC cache entry '/vagrant/html/modules/field/modules/text/text.install' (dev=21 ino=69099) was on gc-list for 3871 seconds in Unknown on line 0 Warning: Unknown: GC cache entry '/vagrant/html/includes/database/mysql/schema.inc' (dev=21 ino=40221) was on gc-list for 3871 seconds in Unknown on line 0 Warning: Unknown: GC cache entry '/vagrant/html/includes/database/schema.inc' (dev=21 ino=40203) was on gc-list for 3871 seconds in Unknown on line 0 Warning: Unknown: GC cache entry '/vagrant/html/includes/install.inc' (dev=21 ino=40192) was on gc-list for 3871 seconds in Unknown on line 0
What is GC cache?
Also note that here http://drupal.stackexchange.com/questions/46085/programatically-remove-a-field-from-a-node
While calling field_delete_field() and field_purge_batch() works, it keeps records in field_config_instance and field_config. Why is that? – berkes Oct 9 '12 at 13:46
Running
SELECT TABLE_SCHEMA, TABLE_NAME
FROM information_schema.tables
WHERE TABLE_NAME LIKE '%deleted%'
returns 5 tables.
@aaronschachter
Copy link
Author

ok one last time. changing node title to 719.

Great! I am not losing my mind. The 2 field_data_field_partners and field_data_field_partners_fc now exist in this database pull, and the local node title has been updated to 719 as well.

Doing the features revert locally on this branch https://github.com/aaronschachter/dosomething/tree/partners_fix must be creating the field_data_field_partners_fc into the staging database. now when I do the drush -y fra it will complain about the table already existing.

disabling solr locally

vagrant@dev:/vagrant/html$ drush -y dis apachesolr
The following extensions will be disabled: apachesolr, apachesolr_search, dosomething_search
Do you really want to continue? (y/n): y
WD php: DatabaseSchemaObjectExistsException: Table field_data_field_partners_fc [error]
already exists. in DatabaseSchema->createTable() (line 657 of
/vagrant/html/includes/database/schema.inc).
Cannot modify header information - headers already sent by (output started at [warning]
/opt/drush-6.2.0/includes/output.inc:38) bootstrap.inc:1217
DatabaseSchemaObjectExistsException: Table field_data_field_partners_fc already exists. in DatabaseSchema->createTable() (line 657 of /vagrant/html/includes/database/schema.inc).

  • All field_deleted_ tables are empty

I think we need to go back to just testing the removal first with this branch https://github.com/aaronschachter/dosomething/tree/remove_partners
Simply just kill the field and clean up the field_deleted tables like nothing ever happened. The mystery is how i'm removing and adding tables from within the vagrant instance. I'm suspecting solr could be changing it or possibly any of the drush alias stuff? But that seems impossible since I tested that drush command to save a node title locally. It worked locally and not on stage.

@aaronschachter
Copy link
Author

new pull from stage, on the remove_partners branch. Has both partners and partners_fc tables. maybe reverting and just trying to remove the thing will work (not trying to add partners_fc like in the partners_fix branch)

drush -y fra
The following modules will be reverted: dosomething_taxonomy, dosomething_image, dosomething_campaign, dosomething_static_content
Do you really want to continue? (y/n): y
Reverted dosomething_taxonomy.user_permission. [ok]
Reverted dosomething_image.image. [ok]
Reverted dosomething_campaign.variable. [ok]
Reverted dosomething_static_content.user_permission. [ok]
Reverted dosomething_static_content.variable. [ok]
vagrant@dev:/vagrant/html$

Ok that looks promising

Refreshing tables. still have field_partners and field_partners_fc and all 10 tables

Lets go for the gold here and try to drush field-delete field_partners

vagrant@dev:/vagrant/html$ drush field-delete field_partners
Do you want to delete the field_partners field? (y/n): y
WD php: DatabaseSchemaObjectExistsException: Cannot rename [error]
field_data_field_partners to field_deleted_data_87: table field_deleted_data_87
already exists. in DatabaseSchema_mysql->renameTable() (line 307 of
/vagrant/html/includes/database/mysql/schema.inc).
Cannot modify header information - headers already sent by (output started at [warning]
/opt/drush-6.2.0/includes/output.inc:38) bootstrap.inc:1217
DatabaseSchemaObjectExistsException: Cannot rename field_data_field_partners to field_deleted_data_87: table field_deleted_data_87 already exists. in DatabaseSchema_mysql->renameTable() (line 307 of /vagrant/html/includes/database/mysql/schema.inc).
Drush command terminated abnormally due to an unrecoverable error.

Ok. So that's the kicker. It looks like Features is taking care of the deletion, yet its not actually changing the field_partners table name to field_deleted whatever. So.. to research, is this a feature things or a field collection thing?

@aaronschachter
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment