I just upgraded a site of mine from Drupal 4 to 5. Everything worked fine but the images....none of the images are visible. I can access the nodes but no images are showing. I can add new images and they are fine.

When I first did the Drupal 4 to 5 upgrade, there was an error that the image table didn't exist. I looked around and it seems to me that this a new table in v5 so I disabled the image module, uninstalled it and reinstalled it....I have a feeling this was the wrong thing to do but I'm now not sure what I should restore from my backup to try a different method of upgrading (even tho I'm not sure what to do different).

I hope I can find someone that has had this same issue - I know the version is old and unsupported...but I'm betting someone out there had the same issue!

Comments

mdowsett’s picture

Looking thru the database and the image.install file, I'm guessing it was supposed to move the images to it's new (to d5) 'image' table.

Can I run this part of the image.install file and expect it to fix things up:

/**
 * Move image files into their own table.
 * 
 * First update for the 5.2 branch, using the update naming convention layed
 * out in: http://drupal.org/node/114774#update-n
 */
function image_update_5200() {
  $ret = array();

  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("CREATE TABLE {image} (
          `nid` INTEGER UNSIGNED NOT NULL,
          `fid` INTEGER UNSIGNED NOT NULL,
          `image_size` VARCHAR(32) NOT NULL,
          PRIMARY KEY (`nid`, `image_size`),
          INDEX image_fid(`fid`)
        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
      break;
    case 'pgsql':
      $ret[] = update_sql("CREATE TABLE {image} (
          nid int_unsigned NOT NULL,
          fid int_unsigned NOT NULL,
          image_size VARCHAR(32) NOT NULL,
          PRIMARY KEY (nid, image_size)
        );");
      $ret[] = update_sql("CREATE INDEX {image_fid} on {image}(fid);");
      break;
  }
  // Copy image files records into the new table.
  $args = array_map('db_escape_string', array_keys(image_get_sizes()));
  $cond = " IN ('". implode("', '",  $args) ."')";
  $ret[] = update_sql("INSERT INTO {image} SELECT DISTINCT f.nid, f.fid, f.filename FROM {files} f INNER JOIN {node} n ON f.nid = n.nid WHERE n.type='image' AND f.filename". $cond);

  // Remove old file_revision records.
  $ret[] = update_sql("DELETE FROM {file_revisions} WHERE EXISTS (SELECT * FROM {image} WHERE {image}.fid = {file_revisions}.fid)");

  return $ret;
}

I just don't want to mess things up further.

sun’s picture

Status: Active » Closed (duplicate)