So I recently deployed my Rails backend server to Heroku.
After a little struggling with passing from SQLite to PostgreSQL, I finally got everything running.
Now the problem is, I did rake db:create and rake db:migrate and that went without any errors but now when I make a REST call to the server I have this error (complete) :
2019-07-31T19:42:16.534355+00:00 app[web.1]: I, [2019-07-31T19:42:16.534259 #4] INFO -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] Started POST "/sessions" for 91.176.204.35 at 2019-07-31 19:42:16 +0000
2019-07-31T19:42:16.535824+00:00 app[web.1]: I, [2019-07-31T19:42:16.535063 #4] INFO -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] Processing by SessionsController#create as */*
2019-07-31T19:42:16.535947+00:00 app[web.1]: I, [2019-07-31T19:42:16.535882 #4] INFO -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] Parameters: {"email"=>"[email protected]", "password"=>"[FILTERED]"}
2019-07-31T19:42:16.566455+00:00 app[web.1]: I, [2019-07-31T19:42:16.566340 #4] INFO -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] Completed 500 Internal Server Error in 30ms (ActiveRecord: 11.2ms)
2019-07-31T19:42:16.567845+00:00 app[web.1]: F, [2019-07-31T19:42:16.567772 #4] FATAL -- : [047c870d-8791-4ec7-90df-a7998b8b17c5]
2019-07-31T19:42:16.567954+00:00 app[web.1]: F, [2019-07-31T19:42:16.567879 #4] FATAL -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "users" does not exist
2019-07-31T19:42:16.567957+00:00 app[web.1]: LINE 8: WHERE a.attrelid = '"users"'::regclass
2019-07-31T19:42:16.567959+00:00 app[web.1]: ^
2019-07-31T19:42:16.567961+00:00 app[web.1]: : SELECT a.attname, format_type(a.atttypid, a.atttypmod),
2019-07-31T19:42:16.567962+00:00 app[web.1]: pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,
2019-07-31T19:42:16.567964+00:00 app[web.1]: c.collname, col_description(a.attrelid, a.attnum) AS comment
2019-07-31T19:42:16.567965+00:00 app[web.1]: FROM pg_attribute a
2019-07-31T19:42:16.567966+00:00 app[web.1]: LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum
2019-07-31T19:42:16.567968+00:00 app[web.1]: LEFT JOIN pg_type t ON a.atttypid = t.oid
2019-07-31T19:42:16.567969+00:00 app[web.1]: LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation
2019-07-31T19:42:16.567971+00:00 app[web.1]: WHERE a.attrelid = '"users"'::regclass
2019-07-31T19:42:16.567972+00:00 app[web.1]: AND a.attnum > 0 AND NOT a.attisdropped
2019-07-31T19:42:16.567973+00:00 app[web.1]: ORDER BY a.attnum
2019-07-31T19:42:16.567975+00:00 app[web.1]: ):
2019-07-31T19:42:16.568064+00:00 app[web.1]: F, [2019-07-31T19:42:16.568002 #4] FATAL -- : [047c870d-8791-4ec7-90df-a7998b8b17c5]
2019-07-31T19:42:16.568171+00:00 app[web.1]: F, [2019-07-31T19:42:16.568104 #4] FATAL -- : [047c870d-8791-4ec7-90df-a7998b8b17c5] app/controllers/sessions_controller.rb:5:in `create'
I have a PostgreSQL add-on installed and it is running. (Otherwise the Rails server wouldn't even boot).
So why do I get this kind of errors on each request? I checked in console and if I do something like User.all I get this :
ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR: relation "users" does not exist)
LINE 1: SELECT "users".* FROM "users" LIMIT $1
^
: SELECT "users".* FROM "users" LIMIT $1
This gets me so confused, what did I do wrong?