1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00
fab-manager/db/migrate/20190107111749_protect_accounting_periods.rb

17 lines
678 B
Ruby
Raw Normal View History

# frozen_string_literal:true
2019-01-07 12:29:52 +01:00
class ProtectAccountingPeriods < ActiveRecord::Migration[4.2]
2019-01-07 12:29:52 +01:00
# PostgreSQL only
def up
return if Rails.env.development? || Rails.env.test?
execute("CREATE RULE accounting_periods_del_protect AS ON DELETE TO #{AccountingPeriod.arel_table.name} DO INSTEAD NOTHING;")
execute("CREATE RULE accounting_periods_upd_protect AS ON UPDATE TO #{AccountingPeriod.arel_table.name} DO INSTEAD NOTHING;")
2019-01-07 12:29:52 +01:00
end
def down
execute("DROP RULE IF EXISTS accounting_periods_del_protect ON #{AccountingPeriod.arel_table.name};")
execute("DROP RULE IF EXISTS accounting_periods_upd_protect ON #{AccountingPeriod.arel_table.name};")
2019-01-07 12:29:52 +01:00
end
end