###前提・実現したいこと
Ruby on Rails で、マイグレーションファイルを削除したいです。
ターミナル上は問題がないのですが、sublime text上からファイルが消えません。
よろしくお願いいたします。
その前に、テーブルのカラムを削除しようとしたら、ActiveRecord::PendingMigrationErrorが出ました。
rake db:migrate RAILS_ENV=developmentをしてくださいと指示が出たので、それをしましたが、変わらずエラーが出るので、そのマイグレーションファイルを削除しようとしています。
###該当のソースコード
マイグレーションファイル #20170518145453_remove_lastest_news_1_to_groups.rb class RemoveLastestNews1ToGroups < ActiveRecord::Migration def change remove_column :groups, :lastest_news_1, :string remove_column :groups, :lastest_news_2, :string remove_column :groups, :lastest_news_3, :string remove_column :groups, :project_ex_1, :text remove_column :groups, :project_ex_2, :text remove_column :groups, :project_ex_3, :text end end
###試したこととターミナルでの結果
rails d migration RemoveLastestNews1ToGroupsをすると
#ターミナル $ rails d migration RemoveLastestNews1ToGroups Running via Spring preloader in process 1899 invoke active_record remove db/migrate/20170519130435_remove_lastest_news1_to_groups.rb
rake db:migrate RAILS_ENV=developmentをすると
#ターミナル rake db:migrate RAILS_ENV=development == 20170518145453 RemoveLastestNews1ToGroups: migrating ======================= -- remove_column(:groups, :lastest_news_1, :string) rake aborted! StandardError: An error has occurred, all later migrations canceled: Mysql2::Error: Can't DROP 'lastest_news_1'; check that column/key exists: ALTER TABLE `groups` DROP `lastest_news_1` /Users/hi.../Desktop/mdp/db/migrate/20170518145453_remove_lastest_news_1_to_groups.rb:3:in `change' ActiveRecord::StatementInvalid: Mysql2::Error: Can't DROP 'lastest_news_1'; check that column/key exists: ALTER TABLE `groups` DROP `lastest_news_1` /Users/hi.../Desktop/mdp/db/migrate/20170518145453_remove_lastest_news_1_to_groups.rb:3:in `change' Mysql2::Error: Can't DROP 'lastest_news_1'; check that column/key exists /Users/hi.../Desktop/mdp/db/migrate/20170518145453_remove_lastest_news_1_to_groups.rb:3:in `change' Tasks: TOP => db:migrate (See full trace by running task with --trace)
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。