I have the following 2 files:
20161009180554_add_process_functionst_to_db.rb
class AddProcessFunctionstToDb < ActiveRecord::Migration
def up
funcs = File.read(Rails.root.join('db', 'migrate', 'processfunctions.sql').to_s)
execute funcs
end
end
processfunctions.sql
drop function if exists retention_data(ref refcursor, shopId integer);
create or replace function retention_data(ref refcursor, shopId integer) returns refcursor as $$
begin
...
return ref;
end;
$$ language plpgsql;
I am trying to add the function in processfunctions.sql to the database. But when I run
rake db:migrate
I get the following error:
/app/vendor/bundle/ruby/2.2.0/gems/rake-11.3.0/exe/rake:27:in `<top (required)>'
ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near ""
LINE 1:
^
:
drop function if exists retention_data(ref refcursor, shopId integer);
after 'Line 1: ' in the error (what the arrow is pointing at) is a rectangle. Like what you would see if you didn't have the right font installed.
I have removed the blank line on line 1 and changed from CRLF to LF, but neither of those changed anything
processfunctions.sql
contain what you think it does? Maybe have a look at it withcat -vet
or look at a hex dump.