Drupal 5 and Drupal 6 don't have one (or two) of those fields. The reason why that database doesn't contain those fields could be:
- The site was update from Drupal 5 / Drupal 6 to Drupal 7, and the update was not successful
- The database got corrupted
- A module removed the fields from the database
- Those fields were manually removed
What you can do is adding the missing fields to the database, trying to first update the existing fields (in the case the site was updated from a previous Drupal version, and the update was not successful).
The following code should help.
// Drop indexes.
@db_drop_index('url_alias', 'src_language_pid');
@db_drop_unique_key('url_alias', 'dst_language_pid');
// Rename the fields, and increase their length to 255 characters.
@db_change_field('url_alias', 'src', 'source', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
@db_change_field('url_alias', 'dst', 'alias', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
if (db_field_exists('url_alias', 'language')) {
$spec = array(
'description' => "The language this alias is for; if 'und', the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.",
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
);
db_change_field('url_alias', 'language', 'language', $spec);
db_update('url_alias')
->fields(array('language' => LANGUAGE_NONE))
->condition('language', '')
->execute();
}
else {
$spec = array(
'description' => "The language this alias is for; if 'und', the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.",
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
);
db_add_field('url_alias', 'language', $spec);
}
// Add indexes back.
@db_add_index('url_alias', 'source_language_pid', array('source', 'language', 'pid'));
@db_add_index('url_alias', 'alias_language_pid', array('alias', 'language', 'pid'));
If this code doesn't get the missing fields, then it was not a failed update. In this case, you can use the following code, which should be used when you are sure the site was not updated from a Drupal version that is earlier than Drupal 7.
// Drop indexes.
@db_drop_index('url_alias', 'src_language_pid');
@db_drop_unique_key('url_alias', 'dst_language_pid');
$spec = array(
'description' => "The language this alias is for; if 'und', the alias will be used for unknown languages. Each Drupal path can have an alias for each supported language.",
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
);
db_add_field('url_alias', 'language', $spec);
$spec = array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => ''
);
db_add_field('url_alias', 'source', $spec);
// Add indexes back.
@db_add_index('url_alias', 'source_language_pid', array('source', 'language', 'pid'));
@db_add_index('url_alias', 'alias_language_pid', array('alias', 'language', 'pid'));
The code has been written basing on the update code used from the System module when updating a previous Drupal version. The part I added is the one to create the database fields, since database fields are normally created during a Drupal installation.