I started out using Rolify in a Rails app and created a migration to set up its tables about 15 migrations ago. I've now decided to replace it with my own code and want to revert that one migration without touching all of the later migrations. The database is in use now, so reverting 15, removing the one I don't want to add and then applying the subsequent 14 would destroy data.
Section 3.11 of the Rails Guide on migrations suggests that this can be done by creating a new migration which reverts the specific old migration by name:
class FixupExampleMigration < ActiveRecord::Migration
def change
revert ExampleMigration
create_table(:apples) do |t|
t.string :variety
end
end
end
I tried to customise this to my context, which would look like this:
class RolifyDestroyRoles < ActiveRecord::Migration
def change
revert RolifyCreateRoles
end
end
(The first line of my original Rolify migration was class RolifyCreateRoles < ActiveRecord::Migration
). However, I get a namespace error:
StandardError: An error has occurred, this and all later migrations canceled:
uninitialized constant RolifyDestroyRoles::RolifyCreateRoles/home/slack/rails/tracker/db/migrate/20150127093921_rolify_destroy_roles.rb:3:in `change'
Maybe something has changed in Rails 4. Does anyone know how I should refer to RolifyCreateRoles so that Rails can find it?