Sie sind hier

Auch hier: Projekt Strandfigur

I'm using Drupal from several sites as a CMS/CMF, e.g. Buildd.Net and Drupal upgrades its database with a dedicated script, which usually works well. But I experienced some problems with taxonomy terms and nodes after upgrade finished. For example all forum articles are "lost". They are still there but have lost information to which taxonomy term they belong. And because Drupal uses taxonomy terms for its forum tree, no forum article is displayed any longer.
Same problem is with Blog articles that are tagged with taxonomy terms: the node is still there, but the taxonomy information is lost.

Looking at the databases table term_node for Drupal5 and Drupal6 makes the difference visible:

CREATE TABLE term_node
nid int_unsigned NOT NULL DEFAULT '0'::int_unsigned,
tid int_unsigned NOT NULL DEFAULT '0'::int_unsigned,
CONSTRAINT term_node_pkey PRIMARY KEY (tid, nid)
ALTER TABLE term_node OWNER TO drupal5;

CREATE TABLE term_node
nid int_unsigned NOT NULL DEFAULT ('0'::int_unsigned)::int_unsigned,
tid int_unsigned NOT NULL DEFAULT ('0'::int_unsigned)::int_unsigned,
vid int_unsigned NOT NULL DEFAULT 0
ALTER TABLE term_node OWNER TO drupal6;

So, obviously the update script of Drupal misses to store the additional table row vid somehow. At least all the difference in the table schema causes the loss of taxonomy terms of those nodes.

So, I wrote a little script called bin/ to fix that problem for my PostgreSQL databases:

# name: bin/
# usage: bin/ DBUSER drupal5-db drupal6-db


ERG=`psql -t -U $USER ${DB1} -c "select nid, tid from term_node" | sed -e 's/|/:/g' | tr -d " "`

for line in `echo $ERG`; do
nid=`echo $line | cut -f1 -d":"`
tid=`echo $line | cut -f2 -d":"`
vid=`psql -t -U $USER ${DB2} -c "select vid from node where nid=${nid}" | tr -d " "`
vid2=`psql -t -U $USER ${DB2} -c "select vid from term_node where nid=${nid} and tid=${tid}"`
if [ -z $vid2 ]; then
psql -U $USER ${DB2} -c "insert into term_node (nid, tid, vid) values ('${nid}', '${tid}', '${vid}')"
echo "inserted: ${nid}, ${tid}, ${vid}"
echo "OK: ${nid}, ${tid}, ${vid}"

It works for me![TM]
Use it at your own risk!



Sehr gut. Der Anfang ist am schwierigsten. Ich spreche aus Erfahrung. Viel Erfolg.

Danke! Ich hoffe, dass dieses Jahr die Kniee mitmachen. Letztes Jahr hatte ich es zwar schonmal versucht, aber Beschwerden im rechten Knie gehabt. Orthopaede und MRT konnten aber nichts finden... mal schauen, wie das nun wird...


Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer