I'm trying to get back into RoR after a long hiatus, and was getting an error when I tried to rails db:migrate
:
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:
the errors continue...
I'm thinking its because of the gem ratyrate
.
In one of the migration files:
class CreateRatingCaches < ActiveRecord::Migration
def self.up
create_table :rating_caches do |t|
t.belongs_to :cacheable, :polymorphic => true
t.float :avg, :null => false
t.integer :qty, :null => false
t.string :dimension
t.timestamps
end
add_index :rating_caches, [:cacheable_id, :cacheable_type]
end
def self.down
drop_table :rating_caches
end
end
is it because rails 5 don't use def self.up
/ def self.down
? and instead should be using def change
?
If that's the case, is it okay for me to just change the def setf.up
to def change
and then remove the def self.down
block?
In addition to this, why is there even a def self.down
calling to drop the table when its creating the table? Does it not get executed, only when you db:rollback
the database?
Thanks