class CreatePopularityPgFunctions < ActiveRecord::Migration[5.2]
def up
execute %{
CREATE OR REPLACE FUNCTION popularity(count integer, weight integer default 3) RETURNS integer AS $$
SELECT count * weight
$$ LANGUAGE SQL IMMUTABLE;
}
end
def down
execute 'drop function popularity(integer, integer) cascade'
end
end