【发布时间】:2020-09-20 10:30:56
【问题描述】:
我如何回滚或删除此公式干净我尝试 def up 和 def down 但不迁移
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
这是另一个代码
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
【问题讨论】:
-
您是否创建了迁移以删除该表?有什么理由不能选择吗?
-
是的,但我想删除我所做的,我如何删除表格,
-
类 CreateTrackerSubtask 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
标签: mysql ruby-on-rails ruby