-
-
Save aaronschachter/9291760 to your computer and use it in GitHub Desktop.
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. | |
New stage db.
vagrant@dev:/vagrant/html$ drush -y pm-disable apachesolr
The following extensions will be disabled: apachesolr, apachesolr_search, dosomething_search
Do you really want to continue? (y/n): y
apachesolr was disabled successfully. [ok]
apachesolr_search was disabled successfully. [ok]
dosomething_search was disabled successfully. [ok]
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 [warning]
started at /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
manually deleted all 10 field_deleted_ / revision tables.
attempted again to field-delete and it completes. all the revision tables are back again.
drush php-eval "field_purge_batch(10);"
WD php: EntityFieldQueryException: Unknown field: field_partners in [error]
EntityFieldQuery->addFieldCondition() (line 765 of
/vagrant/html/includes/entity.inc).
EntityFieldQueryException: Unknown field: field_partners in EntityFieldQuery->addFieldCondition() (line 765 of /vagrant/html/includes/entity.inc).
Drush command terminated abnormally due to an unrecoverable error
Same thing.
drush -y fra
array_merge(): Argument #1 is not an array image.module:586 [warning]
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.
drush php-eval "field_purge_batch(10);"
WD php: EntityFieldQueryException: Unknown field: field_partners in [error]
EntityFieldQuery->addFieldCondition() (line 765 of
/vagrant/html/includes/entity.inc).
EntityFieldQueryException: Unknown field: field_partners in EntityFieldQuery->addFieldCondition() (line 765 of /vagrant/html/includes/entity.inc).
Drush command terminated abnormally due to an unrecoverable error. [error]
THIS. https://drupal.org/comment/6264220#comment-6264220
"Also you need to run it twice: First run is for deleting all data, second run is for deleting the field(s) itself."
Truncated all field_deleted and field_deleted_revision tables first.
Then run field_purge_batch(1000) and all the tables are removed from the db.
Uh .. what? when i download from staging all the field_deleted_tables are gone. all of the aboe was just done using drush commands on my local and using Sequel Pro to truncate those field_deleted tables from my local.
am i running drush commands on staging somehow with the aliases?
Pulled DB down. Yeah there's no field_deleted tables anymore.
Do you want to delete the field_partners field? (y/n): y
vagrant@dev:/vagrant/html$ drush php-eval "field_purge_batch(1000);"
WD Apache Solr: HTTP Status: 0; Message: Request failed: Connection [error]
timed out; Response: ; Request: Unknown; Caller:
call_user_func_array() (line Unknown of Unknown)
WD Apache Solr: HTTP 0; Request failed: Connection timed out [error]
WD php: EntityFieldQueryException: Unknown field: field_partners in [error]
EntityFieldQuery->addFieldCondition() (line 765 of
/vagrant/html/includes/entity.inc).
EntityFieldQueryException: Unknown field: field_partners in EntityFieldQuery->addFieldCondition() (line 765 of /vagrant/html/includes/entity.inc).
Drush command terminated abnormally due to an unrecoverable error. [error]
vagrant@dev:/vagrant/html$
NOW all the field_deleted tables are back again. Going to pull down from staging to see if they're on staging db.
Ok, Aaron Test 555 record has been updated. validated that i've grabbed the latest version of the db, and the field_deleted tables are definitely there.
I'm testing this one more time. Going to truncate the deleted tables.
Done. Next i want to run a sanity check. Tested a node_load(582) and set its title functioin from php-eval to make sure its writing to my local dev site. It is.
vagrant@dev:/vagrant/html$ drush php-eval "dosomething_campaign_tester();"
WD Apache Solr: HTTP Status: 0; Message: Request failed: Connection [error]
timed out; Response: ; Request: Unknown; Caller:
call_user_func_array() (line Unknown of Unknown)
WD Apache Solr: HTTP 0; Request failed: Connection
Next lets double check Sequel Pro to make sure the title's updated there too and i'm looking in all the right places. yes, sanity check has passed. And all the field_deleted tables are in the database.
drush php-eval "field_purge_batch(1000);"
Ran without any errors.
Refresh tables and the tables still exist.
Ran it again. Refresh tables and they are still there. Let's grab staging db again.
In new copy of staging db, title was overwritten so def from staging. and tables still exist as well. Maybe it was the features revert all that does it.
drush -y fra
DatabaseSchemaObjectExistsException: Table field_data_field_partners_fc already exists. in DatabaseSchema->createTable() (line 657 of /vagrant/html/includes/database/schema.inc).
All deleted tables still exist.
drush php-eval "field_purge_batch(1000);"
Seemed to take a little longer but all the deleted tables are still there. Trying again
drush php-eval "field_purge_batch(1000);"
nope, still there.
wonder if turning off solr helped.
let's try this. delete the partners_fc tables manually. drush -y fra, so the table won't exist.
The following modules will be reverted: dosomething_image, dosomething_campaign, dosomething_static_content
Do you really want to continue? (y/n): y
Reverted dosomething_image.image. [ok]
Reverted dosomething_campaign.field_instance. [ok]
Reverted dosomething_static_content.user_permission. [ok]
Reverted dosomething_static_content.variable.
All deleted tables still exist in DB lets try to field purge again
drush php-eval "field_purge_batch(1000);"
nope still there, once more
drush php-eval "field_purge_batch(1000);"
Nope
Attempting to disable apachesolr as last thing to test to see if that made it go away.
drush -y fra
vagrant@dev:/vagrant/html$ drush -y fra
array_merge(): Argument #1 is not an array image.module:586 [warning]
The following modules will be reverted: dosomething_taxonomy, dosomething_image, dosomething_campaign
Do you really want to continue? (y/n): y
WD php: DatabaseSchemaObjectExistsException: Table [error]
field_data_field_partners_fc already exists. in
DatabaseSchema->createTable() (line 657 of
/vagrant/html/includes/database/schema.inc).
Cannot modify header information - headers already sent by (output [warning]
started at /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).
Drush command terminated abnormally due to an unrecoverable error. [error]
OK lets try to delete field_data_partners_fc tables, and drush -y fra to see what happens.
drush -y fra
The following modules will be reverted: dosomething_image, dosomething_campaign
Do you really want to continue? (y/n): y
Reverted dosomething_image.image. [ok]
Reverted dosomething_campaign.field_instance.
Ok. thats weird the tables don't get created... but its because dosomething_taxonomy was already reverted so this was fucked. Here's the next one.
Ok new copy of staging and on the partners_fix branch.
The field_data_field_partners tables are there, the field_data_field_partners_fc tables are not.
The 10 field_deleted tables are present as well.
drush -y fra should work now, because partners_fc doesn't exist. How it doesn't, I'm not exactly sure but maybe what's been missing is the drush -y fra first. Maybe doing the field_purge_batch stuff before a fra messes with things, because the feature definitions don't match whatever is in the db.
SO
new staging
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.field_base. [ok]
Reverted dosomething_taxonomy.field_instance. [ok]
Reverted dosomething_taxonomy.user_permission. [ok]
Reverted dosomething_image.image. [ok]
Reverted dosomething_campaign.field_instance. [ok]
Reverted dosomething_static_content.user_permission. [ok]
Reverted dosomething_static_content.variable.
This looks great. Let's inspect DB.
All field_deleted data stuff exists.
We also have field_data_field_partners and field_data_field_partners_fc. Makes sense.
Theoretically what should happen next is deleting the field. Let's try that.
drush field-delete field_partners
u 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 [warning]
started at /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. [error]
vagrant@dev:/vagrant/html$
Refresh tables. field_data_field_partners still exists and the deleted field is all set to 1. should have checked for what it was before running the delete. anyway, lets see what field_purge_batch does now.
drush php-eval "field_purge_batch(1000);"
WD Apache Solr: HTTP Status: 0; Message: Request failed: Connection timed out; [error]
Response: ; Request: Unknown; Caller: call_user_func_array() (line Unknown of
Unknown)
WD Apache Solr: HTTP 0; Request failed: Connection timed out
Ok, still have partners and partners_fc tables, and 10 deleted tables. All deleted tables are empty (should have checked if they were empty before)
For shits and giggles lets try to run it a second time, maybe that will actually delete the deleted tables per that run it twice comment. It runs again without errors, fast. All the deleted tables still exist.
Try once more drush field-delete field_partners
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).
new rule? Don't do the old field_type switcharoo to try to save the field_name value. New rule to never do this and prevent possibly with a field naming convention with the type in the name so it'd be unique per type. field_partners_fc, field_partners_term, field_partners_node, field_partners_image etc.
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.
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?
Continues in day 2 https://gist.github.com/aaronschachter/4e7d47ae105a1da1a2af
More weird shit.
If I manually delete all of the
field_deleted_data_
andfield_deleted_revision_
tables, as some suggest doing, the call todrush php-eval "field_delete_field("field_partners");
completes without errors. Thefield_data_field_partners
table and its revision are also removed from the database.However, refreshing the tables int he DB, now there are even more field_deleted, field_deleted_revision tables.
Then strangely
vagrant@dev:/vagrant/html$ drush php-eval "field_purge_batch(10);"
WD php: EntityFieldQueryException: Unknown field: field_partners in [error]
EntityFieldQuery->addFieldCondition() (line 765 of
/vagrant/html/includes/entity.inc).
EntityFieldQueryException: Unknown field: field_partners in EntityFieldQuery->addFieldCondition() (line 765 of /vagrant/html/includes/entity.inc).
Drush command terminated abnormally due to an unrecoverable error. [error]
vagrant@dev:/vagrant/html$
This may be because I'm on dev, and
field_partners
does still exist in thedosomething_taxonomy
feature. Going to test from the remove_partners branch and see if I still get the error uponfield_purge_batch
All field_deleted_ tables still exist.