I've got a Rails app that works fine in development and testing, but in production, where it is configured to use a remote Postgresql database, it is failing to create its table. The database is setup and working. I can connect to it via psql as the app, from the production server, using the same configuration that I specify in my database.yml, and then I can create and query tables with commands, no problem.
When I execute database-related rake tasks, everything looks good:
$ rake db:reset
-- create_table("users", {:force=>true})
-> 0.0293s
-- add_index("users", ["username"], {:name=>"index_users_on_username", :unique=>true})
-> 0.0428s
-- initialize_schema_migrations_table()
-> 0.0212s
-- create_table("users", {:force=>true})
-> 0.0097s
-- add_index("users", ["username"], {:name=>"index_users_on_username", :unique=>true})
-> 0.0058s
-- initialize_schema_migrations_table()
-> 0.0092s
No errors. But the table has not been created.
I discovered this by investigating the Nginx error log, but the easiest way to reproduce the error is to fire up the console and do anything with with the app's only model:
$ rails console production
Loading production environment (Rails 4.2.0.beta4)
2.1.3 :001 > all_users = User.all
PG::UndefinedTable: ERROR: relation "users" does not exist
LINE 1: SELECT "users".* FROM "users"
^
I've also ssh'd into the database server and inspected the database with \z
, and it isn't there.
I think the app is connecting to the database server properly, because earlier I was getting permissions errors, and I resolved those. But I don't know how to make sure. And if I do confirm that I am connecting properly, where do I go from there?
Thanks!