Skip default_scope when running migrations

Hi,

I was wondering if there is a way to skip the application of a
named_scope to calls made in legacy migrations. I am working with some
old migrations that include some data manipulation tasks, and my default
scope is preventing those migrations from running. I'm trying to avoid
editing those migration files with with_exclusive_scope.

Thanks,

-G

Hi,

I was wondering if there is a way to skip the application of a
named_scope to calls made in legacy migrations. I am working with some
old migrations that include some data manipulation tasks, and my default
scope is preventing those migrations from running. I'm trying to avoid
editing those migration files with with_exclusive_scope.

Using your application's models in migrations can get you in trouble,
and often in a way that you only notice when deploying in production
(since in development you probably run them one at a time but in
production you'll run all those that were part of the release you are
deploying. If all you need is basic activerecord CRUD type
functionality you can do

class SomeMigration < ...

  class MyModel < ActiveRecord::Base; end

  def self.up
    MyModel.create(...)
  end
end

i.e. you basically have a class that is only used by the migration and
won't depend on any of the changes you may make to the application's
MyModel class.

Fred