0

I have upgraded recently my app to Rails 4 (from Rails 3.2).

But seems that the app doesn't find anymore some mysql tables, for example a table called Accidents.

In the app I find this error:

Mysql2::Error: Table 'gms.accidents' doesn't exist: SHOW FULL FIELDS FROM `accidents`

Ok, it seems that the table doesn't exists anymore, then (seen that is in dev mode and there is no problem to reset the DB), I run in the terminal rake db:schema:load, but:

-- create_table("accidents", {:force=>true})
rake aborted!
Mysql2::Error: Tablespace for table '`gms`.`accidents`' exists. Please DISCARD the tablespace before IMPORT.: CREATE TABLE `accidents`
[...]

What happened? The table doesn't exists but exists??
Why the app doesn't find anymore some tables?

Nimish
  • 1,053
  • 13
  • 29
damoiser
  • 6,058
  • 3
  • 40
  • 66
  • 1
    3 Suggestions: 1. Check your config/database.yml and make sure it has the right connection information. 2. Examine the data in a mysql tool or prompt and check things there 3. Tell us which tables DO work? – Michael Durrant Jun 30 '13 at 11:26
  • thanks @MichaelDurrant for the suggestions. In synthesis: 1. is ok; 2. with a mysql tool the table doesn't exists (don't know why); 3...; I have removed manually the database (with rake db:drop doesn't work...) and then re-create another one. Now seems that work, but it's strange what is happend. – damoiser Jun 30 '13 at 12:21
  • ok then I'll post that as answer, I've done that too. – Michael Durrant Jun 30 '13 at 13:53

1 Answers1

2

One option (not a fix but may let you move forward).

If this is just a development or local database, drop the database manually and update the schema_migrations table and then rake:db migrate to recreate from scratch.

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
  • just a note: better than rake db:migrate is: 1. rake db:create, 2. rake db:schema:load (so it loads directly the "final" version of db and not all migrations) – damoiser Jun 30 '13 at 15:13
  • Yes that works and can be a better option in many cases. Note of caution: If people have put data updates as well as schema (yes I see this) there can be issues. – Michael Durrant Jun 30 '13 at 15:18