Solved!
Thanks to all so much. It seems was a conflict of the migration versions. I just deleted last records from the scheme_migrations table related with the column renaming. Also i deleted all migrations files in db/migrations related with the renaming.
I have a table products_images
:
class CreateProductsImages < ActiveRecord::Migration
def change
create_table :products_images, id: false do |t|
t.references :product
t.references :image
t.integer :position
end
add_index :products_images, [:product_id, :image_id]
add_index :products_images, [:image_id, :product_id]
end
end
When I have tried to start the migration to rename a column position
to priority
rails made migration without any errors. But no changes in DB table products_images
were applied. Of course I could delete the column and create new one with another name. Just a curiosity - why? DB is SQLite.
Migrations of renaming:
variant 1
class RenamePositionToPriority < ActiveRecord::Migration
def change
rename_column :products_images, :position, :priority
end
end
variant 2:
class RenamePositionToPriority < ActiveRecord::Migration
def change
#rename_column :products_images, :position, :priority
change_table :products_images do |t|
t.rename :position, :priority
end
end
end
rake db:rollback outputs:
DL is deprecated, please use Fiddle == RenamePositionToPriority: reverting ======================================= -- rename_column(:products_images, :priority, :position) rake aborted! An error has occurred, this and all later migrations canceled: Missing column products_images.priorityC:in `migrate' Tasks: TOP => db:rollback