I have a complicated issue with Devise and the paranoia(acts_as_paranoid) gem. My User model is relatively simple:
class User < AR::Base
devise :confirmable, :other_config_options
acts_as_paranoid
end
I added the Devise gem first without the confirmable option. Then I later added the confirmable option with this migration:
def up
add_column :users, :confirmed_at, :datetime
add_column :users, :confirmation_token, :string
add_column :users, :confirmation_sent_at, :datetime
add_column :users, :unconfirmed_email, :string
add_index :users, :confirmation_token, unique: true
User.update_all(:confirmed_at => Time.now)
end
No problem up to this point. Then I added the Paranoia gem and the acts_as_paranoid
line to the User model. My database is fine in its current state, but I'm trying to reset my database to sync it with production data, and this is where I'm running into problems. When I do a db:reset, it fails the above migration:
PG::UndefinedColumn: ERROR: column users.deleted_at does not exist
The trouble is that my model contains a directive acts_as_paranoid
that is valid only with the current database snapshot. If I roll back to a previous database snapshot, User::deleted_at
doesn't exist, the paranoia gem still attempts to update only non-deleted objects, and my query fails.
Any thoughts on an elegant way to handle this situation?