I have a Rails 4.2 app on Digital Ocean. After deploying a comments model (with a migrate file), it works fine in development, but not in production. I have been using Capistrano (per this tutorial - https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma) Deploys have been going fine until now.
This was my migrate file (missing from my deploy).
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.references :user, index: true, foreign_key: true
t.text :body
t.references :path, index: true, foreign_key: true
t.timestamps null: false
end
end
end
I checked and can see my schema in both production and dev match and refer to the last reference in the migration files. But when
When I use rails console production, I can see that the comments table is not there. Here is the message in my console.
Loading production environment (Rails 4.2.5)
2.2.1 :001 > Comment.all
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "comments" does not exist
LINE 1: SELECT "comments".* FROM "comments"
^
: SELECT "comments".* FROM "comments"
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `async_exec'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `block in exec_no_cache'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activesupport-4.2.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `exec_no_cache'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:584:in `execute_and_clear'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql/database_statements.rb:160:in `exec_query'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:355:in `select'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:32:in `select_all'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/query_cache.rb:70:in `select_all'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/querying.rb:39:in `find_by_sql'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:639:in `exec_queries'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:515:in `load'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:243:in `to_a'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:630:in `inspect'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/commands/console.rb:110:in `start'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/app_rails_loader.rb:45:in `require'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/app_rails_loader.rb:45:in `block in exec_app_rails'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/app_rails_loader.rb:34:in `loop'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/app_rails_loader.rb:34:in `exec_app_rails'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/lib/rails/cli.rb:5:in `<top (required)>'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/bin/rails:9:in `require'
from /home/laurie/apps/friendlyroad-rails/shared/bundle/ruby/2.2.0/gems/railties-4.2.5/bin/rails:9:in `<top (required)>'
from /home/laurie/.rvm/gems/ruby-2.2.1/bin/rails:23:in `load'
from /home/laurie/.rvm/gems/ruby-2.2.1/bin/rails:23:in `<main>'
from /home/laurie/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `eval'
from /home/laurie/.rvm/gems/ruby-2.2.1/bin/ruby_executable_hooks:15:in `<main>'2.2.1 :002 >
I have tried sudo-apt-get clean as well, I have reset my databases, added the action-pack caching gems and restarted my server several times.
My production log lists the comments view files which aren't rendering (because there is no comments table).
Running rake db:migrate:status shows "no file"
up 20151224215110 Devise create users
up 20151231173736 Add first name last name to users
up 20160112022120 Add role to users
up 20160122204744 Create paths
up 20160123004558 Add attachment image to paths
up 20160124191428 Remove user id from paths
up 20160124191601 Add user id to paths
up 20160124212622 Remove bio from users
up 20160124213023 Add bio to users
up 20160124213311 Remove title from paths
up 20160124213624 Add title content to paths
up 20160204222816 ********** NO FILE **********
checking the directory (production server) I see the file is not there.
Also, deleted old migrations, checked my server for memory, etc. Coming up blank?