I'm current creating a large migration script, where I have to perform the following:

1- Create new posts in table_1

2- Copy the values form table_2 towards the new posts produced in table_1

3- Remove table_2

I developed the up and lower techniques with this migration. My issue is that step two is simply not copying my data properly I have to have the ability to test/debug my code because it runs.

If there's a means please tell me. I'm presently using Rails 2.3.8 but when there's a means for Rails 3 or 3.1 also please tell me.

Thanks

To debug your computer data migration, you should use the ruby-debug jewel and place a breakpoint within the migration code:

require 'ruby-debug'; debugger

Then run the rake task:

rake db:migrate:redo VERSION=whatever_version_number_your_migration_has

Quick ruby-debug tutorial here.

Adjusting data in migrations is not recommended. They must be used simply to edit database structure. But you could relabel existing table, it`s posts and add new posts into it or remove a number of them. Listing of available actions that may be carried out on database via migrations are available at http://api.rubyonrails.org/classes/ActiveRecord/Migration.html

I have learned that you'd be superior of writing the exam for that controller actions which will make use of the fields, instead of testing the migration that contributes the area.

You most likely know the migration itself works in the end as:

1) You've already run it for that development atmosphere

2) You trust rails migrations.

Which means you know you will find the syntax, etc. correct.

Regarding making certain the area can be obtained to be used inside a controller, test the controller.