Can't run rspec - "color_schemes" does not exist


(Kane York) #1

I just booted the VM up again after learning about vagrant suspend (which will save a lot of time, given my frequent full shutdowns), and tried to run the tests, but got a… database statement error?

[vagrant@precise32:/vagrant (translation_overrides)]$ bundle exec rspec spec/components/post_revisor_spec.rb 
2014-05-12T17:46:10Z 5362 TID-164y2s INFO: Sidekiq client with redis options {:url=>"redis://localhost:6379/1", :namespace=>"sidekiq"}
MiniTest::Unit::TestCase is now Minitest::Test. From /usr/local/rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/test/unit/testcase.rb:8:in `<module:Unit>`
SiteSetting(id: integer, name: string, data_type: integer, value: text, created_at: datetime, updated_at: datetime)

--- snip ---

TopTopic(id: integer, topic_id: integer, yearly_posts_count: integer, yearly_views_count: integer, yearly_likes_count: integer, monthly_posts_count: integer, monthly_views_count: integer, monthly_likes_count: integer, weekly_posts_count: integer, weekly_views_count: integer, weekly_likes_count: integer, daily_posts_count: integer, daily_views_count: integer, daily_likes_count: integer, yearly_score: float, monthly_score: float, weekly_score: float, daily_score: float)
/vagrant/vendor/bundle/ruby/2.0.0/gems/seed-fu-discourse-2.2.1/lib/seed-fu/runner.rb:46:in `eval`: PG::Error: ERROR:  relation "color_schemes" does not exist (ActiveRecord::StatementInvalid)
LINE 5:                WHERE a.attrelid = '"color_schemes"'::regclas...
                                          ^
:               SELECT a.attname, format_type(a.atttypid, a.atttypmod),
                     pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
                FROM pg_attribute a LEFT JOIN pg_attrdef d
                  ON a.attrelid = d.adrelid AND a.attnum = d.adnum
               WHERE a.attrelid = '"color_schemes"'::regclass
                 AND a.attnum > 0 AND NOT a.attisdropped
               ORDER BY a.attnum
	from /vagrant/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql_adapter.rb:815:in `block in exec_no_cache`
	from /vagrant/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log`
	from /vagrant/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument`

--- snip ---
	from /vagrant/vendor/bundle/ruby/2.0.0/gems/rspec-core-2.14.7/lib/rspec/core/runner.rb:17:in `block in autorun`

It’s saying that “color_schemes” doesn’t exist, which is weird, because I just saw the db:migrate adding a lot of those:

 - ColorSchemeColor {:id=>89, :name=>"topic-list-star-color", :hex=>"cccccc", :color_scheme_id=>1}
 - ColorSchemeColor {:id=>90, :name=>"topic-list-starred-color", :hex=>"e45735", :color_scheme_id=>1}
 - ColorSchemeColor {:id=>91, :name=>"quote-background", :hex=>"f5f5f5", :color_scheme_id=>1}

Anyone got this before? Should I try to fix this somehow? Should I trash Vagrant and start up a new one?


(Jeff Atwood) #2

:thumbsup: I vote yes.


(Kane York) #3

New error - I’m worried about those “table doesn’t exist” comments…

TopicUser(user_id: integer, topic_id: integer, starred: boolean, posted: boolean, last_read_post_number: integer, seen_post_count: integer, starred_at: datetime, last_visited_at: datetime, first_visited_at: datetime, notification_level: integer, notifications_changed_at: datetime, notifications_reason_id: integer, total_msecs_viewed: integer, cleared_pinned_at: datetime, unstarred_at: datetime, id: integer)
PostRevision(Table doesn't exist)
Category(id: integer, name: string, color: string, topic_id: integer, topic_count: integer, created_at: datetime, updated_at: datetime, user_id: integer, topics_year: integer, topics_month: integer, topics_week: integer, slug: string, description: text, text_color: string, hotness: float, read_restricted: boolean, auto_close_days: float)
TopTopic(Table doesn't exist)
Seeding uncategorized category!
/vagrant/vendor/bundle/ruby/2.0.0/gems/seed-fu-discourse-2.2.1/lib/seed-fu/runner.rb:46:in `eval': PG::Error: ERROR:  column "position" of relation "categories" does not exist (ActiveRecord::StatementInvalid)
LINE 2: ...ption,text_color, user_id, created_at, updated_at, position)
                                                              ^

: INSERT INTO categories
      (name,color,slug,description,text_color, user_id, created_at, updated_at, position)
   VALUES ('uncategorized', 'AB9364', 'uncategorized', '', 'FFFFFF', -1, now(), now(), 1 )
   RETURNING id

from /vagrant/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:128:in `block in execute'
from /vagrant/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:373:in `block in log'
from /vagrant/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
from /vagrant/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/abstract_adapter.rb:367:in `log'
from /vagrant/vendor/bundle/ruby/2.0.0/gems/activerecord-4.1.1/lib/active_record/connection_adapters/postgresql/database_statements.rb:127:in `execute'
from /vagrant/lib/freedom_patches/active_record_base.rb:7:in `exec_sql'
from (eval):14:in `block (2 levels) in run_file'
from /vagrant/vendor/bundle/ruby/2.0.0/gems/seed-fu-discourse-2.2.1/lib/seed-fu/runner.rb:46:in `eval'

EDIT: Doh!

Forgot to RAILS_ENV=test bundle exec db:migrate as well as the normal (development) database.


(joelmoss) #4

I’m getting this while pushing Discourse to heroku, during asset compilation. The code on Heroku is an old version of Discourse.

Problem is, I cannot run rake db:migrate until heroku push is complete, but heroku push fails.

Any ideas? Compile assets locally perhaps?