Change ordergroup default in FinancialTransaction to NULL

The AllowEmtpyOrdergroupInFinancialTransaction migration only changed the
possibility to store NULL values, but did not set the default to NULL.
This commit is contained in:
Patrick Gansterer 2020-08-07 00:36:46 +02:00
parent 7e3c601a25
commit 8cb70d819e

View file

@ -0,0 +1,13 @@
class ChangeOrdergroupDefaultInFinancialTransaction < ActiveRecord::Migration
class FinancialTransaction < ActiveRecord::Base; end
def up
change_column_default :financial_transactions, :ordergroup_id, nil
FinancialTransaction.where(ordergroup_id: 0).update_all(ordergroup_id: nil)
end
def down
FinancialTransaction.where(ordergroup_id: nil).update_all(ordergroup_id: 0)
change_column_default :financial_transactions, :ordergroup_id, 0
end
end