This was going to be a feature request but i don't see how there is a distinction between skip-tables and structure-tables unless structure means it creates the table if it doesn't exist.
The use case is testing with code-driven development. If you have an update hook / Feature that creates a field, and then you make modifications and re-set the database to try it out again... the table for that field exists and the site explodes trying to create it again.
Thus, can --structure-tables-key=common etc. be made to in fact create the structure if not there?
Related: #698264: Better handling of structure-tables and skip-tables options (including cache_* support!)
Comments
Comment #1
moshe weitzman CreditAttribution: moshe weitzman commentedyes, thats correct. structure tables are created but no data is put in them. i don't really understand the request here.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedIs the issue here related to what to do if a table is in both skipped and structure-only?
Comment #3
greg.1.anderson CreditAttribution: greg.1.anderson commentedIt almost sounds to me as if the request were the opposite of what was stated:
If that is the case, then what is desired is for the sql-sync to erase the table that exists in the destination, but not in the source. Structure tables will not do that, but #716412: add a --delete-all-tables-first option for sql-sync ? will.
Maybe close as duplicate?
Comment #4
mlncn CreditAttribution: mlncn commentedCould someone else test this?
I drop all tables in the destination database. When i use --structure-tables-key=common on the sync command, the structure of these tables are not created.
Result when you go to use the example.local: Drupal dies looking for the session table.
Comment #5
moshe weitzman CreditAttribution: moshe weitzman commentedI just setup two sites and did your experiment and it works fine. The @example.local sites works and has a sessions table.
If you run with --verbose, you should see the key bash statement. It is actually two mysqldump calls where the last one appends to the first one. The second one runs with --no-data option. Note the semicolon in the middle of code below:
Please reopen if you can find more info.
Comment #6
mlncn CreditAttribution: mlncn commentedJust the record that i am not completely crazy-- will re-open when i can do proper tests.
Let's run that...
Comment #7
Steven Merrill CreditAttribution: Steven Merrill commentedI just got hit by the same issue. If you are using --structure-tables-key with a sql-dump, the effect is just the same as if you issue a --skip-tables-key, which is to say that neither the data nor the schema for the tables specified are present in the sql dump.
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedAny chance you guys are running this on WIndows? I think it does not recognize semicolon as a delimiter between statements (see #5 ).
Comment #9
moshe weitzman CreditAttribution: moshe weitzman commentedWe changed those semicolons to ampsersands so hopefully this is fixed in master (and 4.x). Please reopen as needed, with a --debug log.
Comment #11
tunicI've come across this bug but I think problem is when non-existent tables are present in the structure tables array.
In my case I wanted to create a drushrc.php file with all common cache tables added to structure table setting (including some tipical tables from common modules). So I have:
Then, dumping and filtering sql by CREATE TABLE statements I got:
(drush-dev is just an alias to drush 5.x-dev)
As you can see, no tables from my structure tables array are created.
But, if I comment that line in drushrc.php I got:
Here they are the lost tables!
If I reduce my structure tables to tables present in database it works ok:
All tables are present, although data skiped tables are shown at the end.
So, I think drush should refuse to create a dump file if a non-existent table is given in structured table setting or it should handle those non-existent tables in strcutured tables settings and dump present tables (without data).
I've tested with drush 4.x-dev and 5.x-dev just downloaded today. Same results with drush 4.x.
Comment #12
moshe weitzman CreditAttribution: moshe weitzman commented@tunic - that does sound like a bug but probably not the cause of everyone else's woes since the 'common' key contains always-present tables. anyway, the easiest fix here is to just error out and refuse to complete the sync since the dump is incomplete.
Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedWe actually had a todo in the code to fix #11. Committed to master and 4.x in commit 43003f6.
Comment #15
DuaelFrSorry to reopen but this issue is still there on the 5.x version.
There is the extract of my drushrc file :
There is the generated mysqldump command :
mysqldump --result-file database_2013-02-07-12-57-02.sql --no-autocommit --single-transaction --opt -Q mydatabase --host=localhost --user=mydatabase --password=mypassword --skip-extended-insert --order-by-primary --ignore-table=mydatabase.cache --ignore-table=mydatabase.cache_block --ignore-table=mydatabase.cache_content --ignore-table=mydatabase.cache_filter --ignore-table=mydatabase.cache_form --ignore-table=mydatabase.cache_gc_map --ignore-table=mydatabase.cache_gc_smap --ignore-table=mydatabase.cache_geonames --ignore-table=mydatabase.cache_gmaps_geocode --ignore-table=mydatabase.cache_gmaps_map --ignore-table=mydatabase.cache_gmaps_smap --ignore-table=mydatabase.cache_gv_map --ignore-table=mydatabase.cache_gv_map_result --ignore-table=mydatabase.cache_gv_smap --ignore-table=mydatabase.cache_gv_smap_result --ignore-table=mydatabase.cache_location --ignore-table=mydatabase.cache_menu --ignore-table=mydatabase.cache_page --ignore-table=mydatabase.cache_path --ignore-table=mydatabase.cache_update --ignore-table=mydatabase.cache_views --ignore-table=mydatabase.cache_views_data --ignore-table=mydatabase.boost_cache --ignore-table=mydatabase.boost_cache_relationships --ignore-table=mydatabase.boost_cache_settings --ignore-table=mydatabase.boost_clearcache --ignore-table=mydatabase.boost_crawler --ignore-table=mydatabase.ctools_css_cache --ignore-table=mydatabase.ctools_object_cache --ignore-table=mydatabase.domain_2_cache_block --ignore-table=mydatabase.domain_2_cache_menu --ignore-table=mydatabase.domain_2_cache_views --ignore-table=mydatabase.domain_2_cache_views_data --ignore-table=mydatabase.domain_2_views_object_cache --ignore-table=mydatabase.flood --ignore-table=mydatabase.search_dataset --ignore-table=mydatabase.search_index --ignore-table=mydatabase.search_node_links --ignore-table=mydatabase.search_total --ignore-table=mydatabase.sessions --ignore-table=mydatabase.views_object_cache --ignore-table=mydatabase.watchdog && mysqldump --no-data --no-autocommit --single-transaction --opt -Q mydatabase --host=localhost --user=mydatabase --password=mypassword --skip-extended-insert --order-by-primary cache cache_block cache_content cache_filter cache_form cache_gc_map cache_gc_smap cache_geonames cache_gmaps_geocode cache_gmaps_map cache_gmaps_smap cache_gv_map cache_gv_map_result cache_gv_smap cache_gv_smap_result cache_location cache_menu cache_page cache_path cache_update cache_views cache_views_data boost_cache boost_cache_relationships boost_cache_settings boost_clearcache boost_crawler ctools_css_cache ctools_object_cache domain_2_cache_block domain_2_cache_menu domain_2_cache_views domain_2_cache_views_data domain_2_views_object_cache flood search_dataset search_index search_node_links search_total sessions views_object_cache watchdog >> database_2013-02-07-12-57-02.sql
Then finally there are the results :
I am using the latest drush 5.x dev version under windows 7 and I get no warning or error during the process.
Comment #16
DuaelFrI made a test by running the two mysqldump commands separately like this
mysqldump --result-file tmpdump.sql --no-autocommit --single-transaction --opt -Q mydatabase --host=localhost --user=mydatabase --password=mypassword --skip-extended-insert --order-by-primary --ignore-table=mydatabase.cache --ignore-table=mydatabase.cache_block --ignore-table=mydatabase.cache_content --ignore-table=mydatabase.cache_filter --ignore-table=mydatabase.cache_form --ignore-table=mydatabase.cache_gc_map --ignore-table=mydatabase.cache_gc_smap --ignore-table=mydatabase.cache_geonames --ignore-table=mydatabase.cache_gmaps_geocode --ignore-table=mydatabase.cache_gmaps_map --ignore-table=mydatabase.cache_gmaps_smap --ignore-table=mydatabase.cache_gv_map --ignore-table=mydatabase.cache_gv_map_result --ignore-table=mydatabase.cache_gv_smap --ignore-table=mydatabase.cache_gv_smap_result --ignore-table=mydatabase.cache_location --ignore-table=mydatabase.cache_menu --ignore-table=mydatabase.cache_page --ignore-table=mydatabase.cache_path --ignore-table=mydatabase.cache_update --ignore-table=mydatabase.cache_views --ignore-table=mydatabase.cache_views_data --ignore-table=mydatabase.boost_cache --ignore-table=mydatabase.boost_cache_relationships --ignore-table=mydatabase.boost_cache_settings --ignore-table=mydatabase.boost_clearcache --ignore-table=mydatabase.boost_crawler --ignore-table=mydatabase.ctools_css_cache --ignore-table=mydatabase.ctools_object_cache --ignore-table=mydatabase.domain_2_cache_block --ignore-table=mydatabase.domain_2_cache_menu --ignore-table=mydatabase.domain_2_cache_views --ignore-table=mydatabase.domain_2_cache_views_data --ignore-table=mydatabase.domain_2_views_object_cache --ignore-table=mydatabase.flood --ignore-table=mydatabase.search_dataset --ignore-table=mydatabase.search_index --ignore-table=mydatabase.search_node_links --ignore-table=mydatabase.search_total --ignore-table=mydatabase.sessions --ignore-table=mydatabase.views_object_cache --ignore-table=mydatabase.watchdog
THEN
mysqldump --no-data --no-autocommit --single-transaction --opt -Q mydatabase --host=localhost --user=mydatabase --password=mypassword --skip-extended-insert --order-by-primary cache cache_block cache_content cache_filter cache_form cache_gc_map cache_gc_smap cache_geonames cache_gmaps_geocode cache_gmaps_map cache_gmaps_smap cache_gv_map cache_gv_map_result cache_gv_smap cache_gv_smap_result cache_location cache_menu cache_page cache_path cache_update cache_views cache_views_data boost_cache boost_cache_relationships boost_cache_settings boost_clearcache boost_crawler ctools_css_cache ctools_object_cache domain_2_cache_block domain_2_cache_menu domain_2_cache_views domain_2_cache_views_data domain_2_views_object_cache flood search_dataset search_index search_node_links search_total sessions views_object_cache watchdog >> tmpdump.sql
And it works well.
I looked into drush to see if it was easily patchable but it is not so I hope you could find a good way to close this bug.
Comment #17
greg.1.anderson CreditAttribution: greg.1.anderson commentedThis issue was marked
closed (won't fix)
because Drush has moved to Github.If desired, you may copy this bug to our Github project and then post a link here to the new issue. Please also change the status of this issue to
closed (duplicate)
.Please ask support questions on Drupal Answers.
Comment #18
Jaypan CreditAttribution: Jaypan commentedQuite pathetic that support for a Drupal plugin cannot be had on Drupal.org.
Someone needs to fork Drush and bring it back to Drupal.org. This is ridiculous.
Comment #19
helmo CreditAttribution: helmo commentedI'm not a fan of it either, but let's not pollute this old issue any further. If you feel strong about it please open a new issue in this or some d.o infra queue to figure out what we need to do to draw Drush back. I know semantic versioning was one of the reaons...