Skip to content

Commit 3864baa

Browse files
committed
Better error when Postgres not running
1 parent 909b838 commit 3864baa

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/avram/migrator/runner.cr

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,25 @@ class Avram::Migrator::Runner
7070
raise <<-ERROR
7171
#{message}
7272
73-
#{green_arrow} If you are on macOS you can install postgres tools from #{macos_postgres_tools_link}
74-
#{green_arrow} If you are on linux you can try running #{linux_postgres_installation_instructions}
75-
#{green_arrow} If you are on CI or some servers, there may already be a database created so you don't need this command"
73+
Try this...
74+
75+
#{green_arrow} If you are on macOS you can install postgres tools from #{macos_postgres_tools_link}
76+
#{green_arrow} If you are on linux you can try running #{linux_postgres_installation_instructions}
77+
#{green_arrow} If you are on CI or some servers, there may already be a database created so you don't need this command"
78+
79+
ERROR
80+
elsif (message = e.message) && messages.includes?("could not connect to database template")
81+
raise <<-ERROR
82+
Creating the database failed. It looks like Postgres is not running.
83+
84+
Message from Postgres:
85+
86+
#{message}
87+
88+
Try this...
89+
90+
▸ Make sure Postgres is running
91+
7692
ERROR
7793
else
7894
raise e

0 commit comments

Comments
 (0)