Question

Job component in app platform to run rails migrations and this error occurs - URI::InvalidURIError: bad URI(is not URI?): ${db.DATABASE_URL}

I have a rails app with a managed development database and I am trying to add a job to migrate my rails app before each deploy.

I set the environment variable DATABASE_URL with a value of ${db.DATABASE_URL}.

But it seems like the connection parameters are not being passed and instead is passing a string directly which causes this error.

URI::InvalidURIError: bad URI(is not URI?): ${db.DATABASE_URL}

How can I pass the database connection parameters correctly in a job?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there Drew,

Is the name of your database db? The syntax is the following:

${<NAME_OF_YOUR_DATABASE>.DATABASE_URL}

If you’ve named your database differently, you need to change the db part accordingly to match your database name.

Let me know how it goes:

Best,

Bobby

Hi @DrewTerry

Try to define your DATABASE_URL as follows:

<%= ENV['DATABASE_URL'] %>

Then you must create the environment variable in .bashrc file:

$ nano ~/.bashrc

Puts your DATABASE_URL variable at the end of the file:

export DATABASE_URL="postgres://user:pass@localhost/dbname"

Finally, saves file and execute the content of the file:

$ source ~/.bashrc

Hope helps you,

Sergio Turpín