Ok this is a general query. How do I update or modify a table and its accompanying files?
For example : I do a ruby script/generate scaffold TABLE_NAME FIELD_NAME1:TYPE FIELD_NAME2:TYPE
I then do a rake db:migrate and everything is generated. Cool. But now I realized I want to rename FIELD_NAME2 to FIELD_NAMEX ; what do I do?
Right now I go in and 1) delete every file generated by the previous generate and rake 2) then do the generate with renamed field 3) then rake all over again.
Now this almost always creates an error and it starts complaining that rake aborted table exists or it doesnt and in this case it is giving this error :
C:\ruby\letter4sure>rake db:migrate version=29 --trace (in C:/ruby/letter4sure) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! uninitialized constant CreatePsoAccounts c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:266:in `load_missing_constant' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in `const_missing' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/inflector.rb:257:in `constantize' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/string/inflections.rb:148:in `constantize' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:386:in `migration_class' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:363:in `migration_classes' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/mysql_adapter.rb:286:in `inject' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:359:in `each' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:359:in `inject' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:359:in `migration_classes' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:339:in `migrate' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:311:in `down' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:300:in `migrate' c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/tasks/databases.rake:85 c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `execute' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `synchronize' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `top_level' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in `top_level' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in `standard_exception_handling' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run' c:/ruby/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7 c:/ruby/bin/rake:16:in `load' c:/ruby/bin/rake:16
Now this is awful. What I am doing wrong here? What I usually do when rake starts acting up is start deleting table and going back down the migration version as you can see above; but this one is still giving me the same error. Why is that?