1

I have some custom functions and triggers, that were run as migrations and added into dev db. However when i run my tests - it seems like test db doesn't have these functions and triggers, and throws errors in specs, which using queries that requires these db-functions. I've tried to manually run rake db:test:clone - but that copies only db structure, not its functions and triggers. How do i create full duplicate for db, keeping not only its structure, but also custom db functions, triggers and views?

PS: Db: postgres

1 Answer 1

2

I recommend you use this setting:

config.active_record.schema_format = :sql

This would create a real sql file containing all details of your db.

And it would be loaded whenever you use rake db:setup

Before changing the setting, you could use rake db:structure:dump to create the sql file.

Sign up to request clarification or add additional context in comments.

1 Comment

With that line, after running rake test, I still get triggers disabled in test database with Rails 5 and PostgreSQL :( I do have reasonable structure.sql and no schema.rb.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.