Sha256: a9edfe1e03cfe2f07b026f130209b0c0ca1a4bad3ea819c71712f83093f30787
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require "spec_helper" describe "Function migrations", :db do around do |example| sql_definition = <<~EOS CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'test'; END; $$ LANGUAGE plpgsql; EOS with_function_definition(name: :test, sql_definition: sql_definition) do example.run end end it "can run migrations that create functions" do migration = Class.new(ActiveRecord::Migration) do def up create_function :test end end expect { run_migration(migration, :up) }.not_to raise_error end it "can run migrations that drop functions" do connection.create_function(:test) migration = Class.new(ActiveRecord::Migration) do def up drop_function :test end end expect { run_migration(migration, :up) }.not_to raise_error end it "can run migrations that updates functions" do connection.create_function(:test) sql_definition = <<~EOS CREATE OR REPLACE FUNCTION test() RETURNS text AS $$ BEGIN RETURN 'testest'; END; $$ LANGUAGE plpgsql; EOS with_function_definition( name: :test, version: 2, sql_definition: sql_definition, ) do migration = Class.new(ActiveRecord::Migration) do def change update_function :test, version: 2, revert_to_version: 1 end end expect { run_migration(migration, :change) }.not_to raise_error end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fx-0.1.0 | spec/features/functions/migrations_spec.rb |