I am developing a Rails web app. I have a table called countries that is associated with two other tables: cities and sites. When I try to change the column code to name in the countries table, I get the following exception:
ActiveRecord::InvalidForeignKey: SQLite3::ConstraintException: FOREIGN KEY constraint failed: DROP TABLE "countries"
I have tried adding the dependent: :destroy thing, but I still get the same exception. I tried dropping the table, and recreating it, and still not working. Any help would be greatly appreciated.
Country model:
class Country < ApplicationRecord
    has_many :cities, dependent: :destroy
    has_many :sites, dependent: :destroy
    has_many_attached :photos
    validates :code, uniqueness: true
    validates :about, presence: true
end
Here is the migration code I'm using to change the name of the column in the countries table:
class FixCodeName < ActiveRecord::Migration[5.2]
def change
    rename_column :countries, :code, :name
  end
end
 
    