1

When I run cap staging deploy:check it succeeds. When I run cap staging deploy it succeeds until deploy:assets:precompile at which I get this error:

 01 ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
 01 rake aborted!
 01 ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR:  relation "links" does not exist
 01 LINE 1: SELECT "links".* FROM "links"

After googling, I believe the problem is that it is trying to create the relations before creating the tables. I have since tried many solutions including placing config.assets.initialize_on_precompile = false in application.rb but none of them work.

I desperately need help. Thank you!

Josiah Palmer
  • 151
  • 1
  • 17

1 Answers1

0

The problem is that the asset:precompile task boots up the full Rails environment. Do you have any initializers or something that use Link model?

Dirty workaround:

ssh to the staging server, go to :deploy_path you've set in capistrano's config and then in last release folder. After that manually run RAILS_ENV=staging bundle exec rake db:migrate.

Vladimir Dimitrov
  • 1,008
  • 7
  • 21
  • I don't have any initializers using my Link model. I do have this -> https://stackoverflow.com/questions/52729750/rails-5-create-vanity-route-for-each-instance-of-model <- going on in my routes.rb. Could that have anything to do with it? – Josiah Palmer Oct 20 '18 at 21:31
  • I also have no app files/folders on the server yet since that all gets created in the `cap staging deploy` action so I can't cd to :deploy_path and run that command. Should I go ahead and clone my repository over to the server and then do that? Will that cause any issues with capistrano? This is my first time deploying like this so capistrano and all that is completely new to me – Josiah Palmer Oct 20 '18 at 21:34
  • 1
    The routes.rb thing was the problem. I commented out the lines and `cap staging deploy` ran fine. Thank you @vladimir-dimitrov for helping me rethink through some of this! – Josiah Palmer Oct 20 '18 at 21:40