0
我想創建一個Sequel遷移,通過列表的表,並嘗試添加一個特定的列,如果該表沒有該列尚未。續集遷移 - 只添加列,如果表還沒有它
例如:
Sequel.migration do
change do
table_list = [:table1, :table2, :table3]
table_list.each do |t|
if t does not have :specific_column yet
alter_table(t) do
add_column :sepcific_column, type: String
end
end
end
end
end
是否可以告訴我們,如果列一個表中已經存在,所以我可以做相應的東西?
甜,你一定意味'除非自[T] ...'哈哈,但它的工作就像一個魅力。謝謝您的幫助! – Edward
你是對的,只是另一種方式;)我會調整答案。 – knut