I have Capistrano set up such that it allows me to deploy the staging version of my Ruby on Rails website to an amazon server from a git repository successfully. However, after deploying, I must run a migration on the database on the server. If I do not, any page with login forms or database-based content cannot load. When I run the migration on the server, I see every singly migration on the site being migrated, not just the most recent ones.
I know that Capistrano can maintain the previous migrations, and I thought it did that automatically. My question is, how do stop the apparent database wipe or loss which is occurring so that a migration is only needed if there are actually new migrations?
I see no unusual errors in the Capistrano output and I am a novice when it comes to Capistrano and databases. I noticed that my database.yml file has no entry for staging and I was wondering if it could be as simple as adding an entry for staging with the database set to db/development.sqlite3?
here is my deploy.rb file:
set :application, "staging"
set :scm, :git
set :repository, "."
set :deploy_via, :copy
#set :copy_cache, true
set :copy_exclude, [".git"]
set :user, "username"
set :use_sudo, false
default_run_options[:pty] = true
server "server_url", :app, :web, :db, :primary => true
set :deploy_to, "/var/www/staging"
# if you want to clean up old releases on each deploy uncomment this:
set :keep_releases, 3
after "deploy:restart", "deploy:cleanup"
# If you are using Passenger mod_rails uncomment this:
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "touch #{File.join(current_path,'tmp','restart.txt')}"
end
end
And my database.yml file:
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000