mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2024-12-13 23:48:55 +01:00
16 lines
644 B
Ruby
16 lines
644 B
Ruby
class ProtectAccountingPeriods < ActiveRecord::Migration
|
|
|
|
# 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;")
|
|
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};")
|
|
end
|
|
end
|