From 2e92e01a24cefe1dc033dbd5e94bdb93fb1f6f4d Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 21 Sep 2019 23:18:36 +0500 Subject: [PATCH] Add methods Partynest::Migration#drop_func, #drop_enum, #drop_constraint --- lib/partynest/migration.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/partynest/migration.rb b/lib/partynest/migration.rb index 68abbda..de7411e 100644 --- a/lib/partynest/migration.rb +++ b/lib/partynest/migration.rb @@ -9,6 +9,13 @@ module Partynest end end + def drop_func(name, sql) + reversible do |dir| + dir.up { func_deletion(name).call } + dir.down { func_creation(name, sql).call } + end + end + def enum(name, values) reversible do |dir| dir.up { enum_creation(name, values).call } @@ -16,6 +23,13 @@ module Partynest end end + def drop_enum(name, values) + reversible do |dir| + dir.up { enum_deletion(name).call } + dir.down { enum_creation(name, values).call } + end + end + def constraint(table, name, check) reversible do |dir| dir.up { constraint_creation(table, name, check).call } @@ -23,6 +37,13 @@ module Partynest end end + def drop_constraint(table, name, check) + reversible do |dir| + dir.up { constraint_deletion(table, name).call } + dir.down { constraint_creation(table, name, check).call } + end + end + private def func_creation(name, sql)