Situation : when using MySql scripts to insert (migrate) data to the D7 field structure.
Issue : many columns in field_data_field_[name] and field_revision_field_[name] are considered PRIMARY, which disallows for example to import two rows with the same entity_id (which is really the node id). This is silly since some content type fields will allow many data, like having two documents attached to the same node.
Though those columns are not set to unique in theory, because they are somehow marked Primary, they cannot be doubled.
Tip : do not use the MySql IGNORE option if you do not want to lose field data/files.
Solution or workaround I found : in PhpMyAdmin, I could modify what columns are Primary. In these cases, I chose field_[name]_fid, since fid numbers must be unique.
I am not an expert, but that did slow down my migration process.
nb: on the other hand, adding two rows from a same field from the online CMS worked (publishing an article for example). The table showed two rows with the same entity_id without issues. Therefore, the Primary key issue does not seem to occur when using the online publishing.
ps: which is why the component marked with this issue is Database rather than Field.
Comments
Comment #2
michael_lessard_micles.biz commentedComment #3
michael_lessard_micles.biz commentedThe word not was missing in two sentences.
Comment #4
David_Rothstein commentedI'm not sure what you mean here. The columns are not primary keys separately (that isn't possible in SQL; each table can have only one primary key). They are combined together into a single primary key. So nothing stops you from having two rows with the same entity_id as long as one of the other columns that makes up the primary key differs between the two rows.
In the case of your example (a field that has more than one value) the "delta" column is used for that. If there are two documents attached to the same node as part of the same field, both will have the same entity_id but the first has a delta of 0 and the second has a delta of 1.
Hope that makes sense...
Comment #5
michael_lessard_micles.biz commentedThank you for the info about the use of the delta column which should bypass the MySql error about duplicate PRIMARY KEY: I will test MySql import using different delta (but I am not hopeful).
Comment #6
michael_lessard_micles.biz commentedFollow-up : after much testing, if the delta number is increased, it does indeed accept a new row with the rest of the data being identical.
My attempts though at MySql scripting delta+1 have failed.
Example - MySql script (not php) :