简体   繁体   中英

how i can remove tables my.sql by ruby on rails

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

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM