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.
I have never encountered this problem but this may solve it:
- Take a backup of your current schema.rb
cp db/schema.rb db/schema.rb.backup
- Delete schema.rb
rm db/schema.rb
- Run
rake db:migrate
This will regenarate your schema.rb file from the current database state.
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.
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.
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.
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.