PG :: DependentObjectsStillExist: ERROR when using rspec

When i run

$rspec "/any_file" 

rspec loads the schema.rb file to configure the database.

I understand that when it comes to this line

 create_table "queue_classic_jobs", force: true do |t|; end 

Rspec launches

 DROP TABLE "queue_classic_jobs" 

teams.

It causes this error

 PG::DependentObjectsStillExist: ERROR: cannot drop table queue_classic_jobs because other objects depend on it (ActiveRecord::StatementInvalid) DETAIL: function lock_head(character varying) depends on type queue_classic_jobs function lock_head(character varying,integer) depends on type queue_classic_jobs HINT: Use DROP ... CASCADE to drop the dependent objects too. : DROP TABLE "queue_classic_jobs" 

It seems to me that I need to do rspec

 DROP TABLE "queue_classic_jobs" CASCADE 

But how?

+6
source share
1 answer

Are you using Rails> = 4.1? There's a new feature in which ActiveRecord tries to synchronize your test circuit with schema.rb without reloading the entire database. You can read about it here: http://guides.rubyonrails.org/4_1_release_notes.html#railties-notable-changes .

Unfortunately, it does not work with foreign keys: https://github.com/rails/rails/issues/14708 . You can disable it by adding this line at the end of config / environment / test.rb:

 config.active_record.maintain_test_schema = false 
+10
source

Source: https://habr.com/ru/post/956404/


All Articles