A platform for community discussion. Free, open, simple.
FIX: Drop readonly function when dropping table
Gerhard Schlager74d78e363648
diff --git a/lib/migration/table_dropper.rb b/lib/migration/table_dropper.rbindex d710b88ff09..8b7e89a3749 100644--- a/lib/migration/table_dropper.rb+++ b/lib/migration/table_dropper.rb@@ -18,6 +18,7 @@ module Migrationdef self.execute_drop(table_name)DB.exec("DROP TABLE IF EXISTS #{table_name}")+ BaseDropper.drop_readonly_function(table_name)endendenddiff --git a/spec/components/migration/table_dropper_spec.rb b/spec/components/migration/table_dropper_spec.rbindex 2f1d2216362..a59da8b9439 100644--- a/spec/components/migration/table_dropper_spec.rb+++ b/spec/components/migration/table_dropper_spec.rb@@ -14,6 +14,16 @@ describe Migration::TableDropper doSQLend+ def function_exists?(function_name, schema_name = 'public')+ DB.exec(<<~SQL) > 0+ SELECT 1+ FROM information_schema.routines+ WHERE routine_type = 'FUNCTION' AND+ routine_name = '#{function_name}' AND+ specific_schema = '#{schema_name}'+ SQL+ end+let(:table_name) { 'table_with_old_name' }before do@@ -56,6 +66,16 @@ describe Migration::TableDropper doexpect(table_exists?(table_name)).to eq(false)end+ it "should drop the read_only function" do+ Migration::TableDropper.execute_drop(table_name)++ schema_name, function_name = Migration::BaseDropper+ .readonly_function_name(table_name)+ .delete_suffix('()').split('.')++ expect(function_exists?(function_name, schema_name)).to eq(false)+ end+it 'should prevent insertions to the table' dobeginDB.exec <<~SQL