Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different environments for one rake task in Rails

is it possible to call a rake task on different environments? That means I have a production database where I want to read out some data and put it to my test database.

The tables in my test database are unknown in the production database and vice versa.

EDIT: they are both NOT my standard environment, so both are not local.

like image 437
cruxi Avatar asked Dec 08 '25 06:12

cruxi


1 Answers

You can check octopus, it's a gem that allows you to choose the database that the query will call, you could use it to specify in your rake from where to read out and put data.

So in your rake, you could do something like (may not be the best way):

@user = User.where(:name => "Test").using(:production_one)
@duplicate_user = @user.dup
Octopus.using(:test_one) do
  @duplicate_user.save
end
like image 130
Khaled Avatar answered Dec 09 '25 19:12

Khaled