0

how i can rollback or remove this formula clean im try def up and def down but not migrate

 class AllowAllTrackersAsSubtasks < ActiveRecord::Migration[5.1]
  def change
    trackers = Tracker.all
    trackers_ids = trackers.pluck(:id)
    trackers.each do |tracker|
      tracker.subtask_ids = trackers_ids
      tracker.save
    end
  end
end

this another code

class CreateTrackerSubtask < ActiveRecord::Migration[5.1]
  def change
    create_table "trackers_subtasks", :id => false, :force => true do |t|
      t.column "tracker_id", :integer, :default => 0, :null => false
      t.column "subtask_id", :integer, :default => 0, :null => false
      t.index [:tracker_id, :subtask_id], :unique => true
    end
  end
end
  • Did you create a migration to remove the table? Is there some reason that isn't an option? – Rockwell Rice Sep 20 '20 at 15:10
  • yes,but i want remove what im do,how i can drop table, – Ashraf Alzyood Sep 20 '20 at 22:18
  • https://stackoverflow.com/questions/4020131/rails-db-migration-how-to-drop-a-table#:~:text=First%20generate%20an%20empty%20migration,it%20creates%20the%20appropriate%20date.&text=The%20only%20thing%20I%20added,drop%20the%20table%20for%20you. – Rockwell Rice Sep 21 '20 at 00:10
  • class CreateTrackerSubtask < ActiveRecord::Migration[5.1] def change drop_table "trackers_subtasks", :id => false, :force => true do |t| t.column "tracker_id", :integer, :default => 0, :null => false t.column "subtask_id", :integer, :default => 0, :null => false t.index [:tracker_id, :subtask_id], :unique => true end end – Ashraf Alzyood Sep 21 '20 at 09:22

1 Answers1

-1

this code work??

class CreateTrackerSubtask < ActiveRecord::Migration[5.1]
  def change
    drop_table "trackers_subtasks", :id => false, :force => true do |t|
      t.column "tracker_id", :integer, :default => 0, :null => false
      t.column "subtask_id", :integer, :default => 0, :null => false
      t.index [:tracker_id, :subtask_id], :unique => true
    end
  end

what another code how i can do?