Is there any chance of testing the PostgreSQL database in this scenario without duplicating the database in the development environment?

"I have a Rails application with a PostgreSQL database. My database contains 1000 records. I wrote a rake that will handle the records in the database. If the rake task went wrong, I want to return the sources back to the database. Is there any chance of testing "Database in this scenario without duplicating the database in the development environment?"

+4
source share
2 answers

In Rails, which has a sandbox function

- - , , rails --sandbox.

 bin/rails console --sandbox
Loading development environment in sandbox 
Any modifications you make will be rolled back on exit
irb(main):001:0>

, . , ( )

http://edgeguides.rubyonrails.org/command_line.html#rails-console

+5

env.

create database test with template original_db;

db, , db

+1

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


All Articles