views:

134

answers:

5

I transfered a project to a new machine. Everything works. I can run migrations and they update the mysql database. However, the schema.rb file doesn't acknowledge the changes. I checked the read/write permissions for schema.rb are OK. Does anyone have any idea about what could cause this problem. I'm using Rails version 2.3.5. rake:redo rake:rollback don't work because the schema is not aware of the changes in database. running rake db:migrate again does nothing.

A: 

I have never encountered this problem but this may solve it:

  1. Take a backup of your current schema.rb cp db/schema.rb db/schema.rb.backup
  2. Delete schema.rb rm db/schema.rb
  3. Run rake db:migrate

This will regenarate your schema.rb file from the current database state.

apod
A: 

Yes but I would then have to re-import all my data again but I suppose you are correct. I wish there was a simple to check whether your sql tables match your schema. I have a lot of tables and just eyeballing them seems too risky.

todd
A: 

Well actually i tried apod solution and the migration worked the first time , proving that I implemented apod solution correctly, however the next time I tried a migration, I got the same problem.

toddq
A: 

You mention that you've checked the file permissions to schema.rb--did you also check the permissions of the db directory? I often find that when I can't write to a single file, the permission issue is more often than not with the containing directory.

vonconrad
A: 

The answer was that I had the following line in my development.rb file config.active_record.schema_format = :sql. After commenting that out, everything worked.

toddq