When i installed newsletter I got a database error like "table field_data_field_institution already exists" . In the newsleter.install file in function newsletter_fields_instances() it creates the fields for each taxonomy. So i have a taxonomy called "institution" and one of my nodes has a field called "institution" . So when newsletter installs, it tries to make the table field_data_field_institution but it already exists for my node field.

I added a simple check for that field to get it installed. Not sure if the module will still work. testing it. A general solution might be to check if field already exists and if so just use the existing field.

function newsletter_fields_instances() {
  $vocabularies = taxonomy_get_vocabularies();
  foreach ($vocabularies as $vocabulary) {
    // Field names have 32 char limit.
    $field_name = 'field_' . substr($vocabulary->machine_name, 0, 26);
    // I already have a field_institution on one of my nodes    if ($field_name == 'field_institution')
    {
      $field_name .= '_news';
    }

    $fields[] = array(
      'field_name' => $field_name,
      'type' => 'taxonomy_term_reference',
      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
....

Thanks

Comments

rsbecker’s picture

Issue summary: View changes

This is a major problem. It seems that when newsletter installs it tries to put every term reference field on the newsletter template. I don't know why that is, but when it throws this error the installation breaks and tables it needs, i.e. the field_newsletter_body, field_newsletter_categories, field_newsletter_list, field_newsletter_template, aren't created.

Then, if you try to uninstall the module it doesn't clean up after itself. Therefore, you cannot reinstall because some of the fields already exist. Either there needs to be more cleanup or there need to be traps to handle fields that exist.

The following error is thrown when attempting to uninstall after a failed install. The error is the same every time, even though there never is a field_deleted_29 or field_deleted_290 in the db.

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'spjdct5_spjdc.field_deleted_data_29' doesn't exist: SELECT field_deleted_data_290.entity_type AS entity_type, field_deleted_data_290.entity_id AS entity_id, field_deleted_data_290.revision_id AS revision_id, field_deleted_data_290.bundle AS bundle FROM {field_deleted_data_29} field_deleted_data_290 WHERE (field_deleted_data_290.deleted = :db_condition_placeholder_0) AND (field_deleted_data_290.bundle = :db_condition_placeholder_1) LIMIT 10 OFFSET 0; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => general ) in field_sql_storage_field_storage_query() (line 585 of /home/spjdct5/public_html/drupal/modules/field/modules/field_sql_storage/field_sql_storage.module).

This is true of the latest dev version as well.