When I try to update a certain site in a Drupal-Multisite-System I got several times the following error

Update #7201
Failed: DatabaseSchemaObjectExistsException: Die Datenbanktabelle file_type ist bereits vorhanden. in DatabaseSchema->createTable() (Zeile 657 von /home/www/web619/html/drupal_7_standard/includes/database/schema.inc).

Translated: The Database table file_type already exists.

When i delete the table the other tables are mentioned: file_type_mimetypes, file_type_streams, field_file_image_alt_text, field_file_image_title_text etc.

The other Sites in the system work now perfect with plupload etc. Media and File Entity are on a good way.
But, what I can do for the damaged site?
Thank you very much for your help.
Hans

Comments

Snakehead’s picture

Priority: Normal » Minor
Status: Active » Closed (fixed)

Meanwhiles i solved the problem like this:

I did deleted first these tables:
file_type_mimetypes
file_type_streams
field_data_field_file_image_alt_text
field_data_field_file_image_title_text
field_revision_field_file_image_alt_text
field_revision_field_file_image_title_text

Then I updated the Drupal site

I recreated all die fields for the file type document from the former site.
I adjusted all the concernded views because of the new title field.
I am happy that this has happened just to experimental Drupal 7 site with less media.
I hope this will never happen again.
Thanks for your attention.
Hans

TechNikh’s picture

thanks Snakehead.

same issue.

The following updates returned messages

file_entity module

Update #7201
Failed: DatabaseSchemaObjectExistsException: Table <em class="placeholder">file_type</em> already exists. in DatabaseSchema->createTable() (line 657 of /**************/includes/database/schema.inc).
PaulUrwin’s picture

I think I have traced this issue to a problem when you revert your database by importing an old SQL export of your database.

1. Take an SQL export
2. install the updates
3. run the database updates
4. you now decide you want to restore the database for some reason so you import your export again
The Export does not include DROP statements for the new tables because they didn't previously exist, so after you import this time the new tables still exist
5. attempt the updates again and you will get the reported error about the tables already existing.

You address this by ensuring you DROP all tables before you import your export.

tchopshop’s picture

See this issue. This solved it for me:
http://drupal.org/node/1267748

tanius’s picture

Issue summary: View changes

This issue happened to me today when upgrading Drupal Commons from 7.x-3.9 to 7.x-3.12. Specifically, I got the following error message when running database update commons_update_3115: "Table file_type already exists."

The reason could be as related in #3 (or possibly a flaw in the database updates for Commons 3.12, not taking into account that file_entity was a dependency in Commons 3.9 already, it was just not enabled).

Anyway, for everyone running into this in the next days, here is how I solved this: first revert to a database backup (since Drupal does not bootstrap at this stage), then delete the problematic tables:

drush sql-query "DROP TABLE file_type";
drush sql-query "DROP TABLE file_display";
drush sql-query "DROP TABLE file_metadata";
drush sql-query "DROP TABLE field_data_field_media";
drush sql-query "DROP TABLE field_revision_field_media";
drush sql-query "DROP TABLE field_data_field_file_image_title_text";
drush sql-query "DROP TABLE field_revision_field_file_image_title_text";
drush sql-query "DROP TABLE field_data_field_file_image_alt_text";
drush sql-query "DROP TABLE field_revision_field_file_image_alt_text";

And finally run the database updates again, this time successfully:

drush update-db;

joyseeker’s picture

I dropped the tables, and after the update, more updates went through, but I'm still getting an error. This time it's a bit different:

Failed: DatabaseSchemaObjectDoesNotExistException: Cannot add field file_type.mimetypes: table doesn't exist. in DatabaseSchema_mysql->addField() (line 325 of ../includes/database/mysql/schema.inc).

creact’s picture

I am having the same issue. Trying to run updates i get:

The following updates returned messages
file_entity module
Update #7204
Failed: DatabaseSchemaObjectExistsException: Table field_data_field_file_image_alt_text already exists. in DatabaseSchema->createTable() (line 657 of /includes/database/schema.inc).

Has anyone solved this yet?

ibonelli’s picture

Hi there,
Just to share another experience I had to do as Tanius did. I was not able to do the upgrade without droping tables first. I'm not sure if it was this module, interaction with others or what.
All I know is that "drush up" could not do the DB updates and that "drush updb" threw all kind of errors. Only way forward was to drop the tables that were blocking the upgrade (as system reported, weren't exactly the same as Tanius).
What I want to add though is that after upgrade drupal crashed due to lack of table "field_data_field_file_image_alt_text", only way to figure it out was using "drush watchdog-show", backend access was not available. To fix it I had to do all over again and before dropping the table do: drush sql-query "SHOW CREATE TABLE field_data_field_file_image_alt_text;". To recreate/run I had to connect directly to the DB (syntax was a bit messy for drush sql-query).

Hope it helps, otherwise just ask! Cheers, Ignacio

crystaldawn’s picture

Status: Closed (fixed) » Active

This should not have been closed since none of the proposed fixes actually work. This problem still exists even in the latest dev build when upgrading from earlier versions. The only workaround is to completely uninstall file_entity and start from scratch. Thats NOT an acceptable upgrade path as far as I'm concerned.

crystaldawn’s picture

Priority: Minor » Major

It should also be set to major since it blocks potential security updates that may eventually be needed since this module simply cannot be 'upgraded' properly.

rameshbalda’s picture

public function createTable($name, $table) {
  if ($this->tableExists($name)) {
    drupal_set_message(t('table already existed: ' . $name));
    return;
   //throw new DatabaseSchemaObjectExistsException(t('Table %name already exists.', array('%name' => $name)));
  }
  $statements = $this->createTableSql($name, $table);
  foreach ($statements as $statement) {
    $this->connection->query($statement);
  }
}

rameshbalda’s picture

joseph.olstad’s picture

Hi @rameshbalda, please edit comment #11 and highlight your code then press the 'PHP' button above the text area you'll be writing in.

this way your code will be formatted correctly for others to enjoy.

Thank you

joseph.olstad’s picture

Status: Active » Closed (works as designed)

most of these issues are resolved, most have upgraded now.