R
R
Robert2015-02-03 17:26:56
Ruby on Rails
Robert, 2015-02-03 17:26:56

Why is old information on the server overwritten when calling cap deploy?

I use capistrano 2.
Without going into the details of the project, I will say that it is possible to upload pictures, and, consequently, the subsequent entry into the database.
But with the next call to cap deploy, all information is overwritten. You have to re-run db:migrate on the machine.
I tried to use cap deploy:update_code - the changes did not take effect.
deploy on locum.ru

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene Burmakin, 2015-02-03
@Jowan

Because every time you deploy, Capistrano creates a new directory in which the latest release of your application is loaded. Accordingly, your images remain in the old directory. You need to set up a symlink in the deploy.rb file with the folders in which the images will be stored, these folders themselves are usually stored in the shared directory higher up the tree relative to the directory containing the releases. I hope I explained clearly :)
And judging by the fact that the information in your database is overwritten, you are using SQLite3 as a database. Lokum provides a database for each project on PostgreSQL, MySQL or some other choice, I recommend moving to PostgreSQL. This database is the de facto standard for Rails applications, although sometimes the choice depends on the project. And SQLite is only for the stage when development on Rails is just being comprehended. Get over earlier - it will be easier in the future.

P
Pavel Bakin, 2015-02-05
@recomp

Here is an example of how to create a symlink with user data in the shared directory / after deployment

task :symlink_shared do
    run "rm -rf  #{current_path}/public/uploads"
    run "ln -nsf #{shared_path}/uploads #{release_path}/public/uploads"
end

after 'deploy:restart', 'symlink_shared'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question