Note that there are some explanatory texts on larger screens.

plurals
  1. POCapistrano "cap deploy:migrations" fails since it tries to run all migrations, not only the pending ones
    text
    copied!<p>I try to deploy with "cap deploy:migrations" since I have 3 new migrations which need to be executed on live server. The result is:</p> <pre><code>executing "cd /home/martin/public_html/project/releases/20110905131238; bundle exec rake RAILS_ENV=production db:migrate" servers: ["50.56.82.190"] [50.56.82.190] executing command ** [out :: 50.56.82.190] == CreateUsers: migrating ==================================================== ** [out :: 50.56.82.190] -- create_table(:users) ** [out :: 50.56.82.190] rake aborted! ** [out :: 50.56.82.190] An error has occurred, all later migrations canceled: ** [out :: 50.56.82.190] ** [out :: 50.56.82.190] Mysql2::Error: Table 'users' already exists: CREATE TABLE `users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `name` varchar(255), `email` varchar(255), `created_at` datetime, `updated_at` datetime) ENGINE=InnoDB ** [out :: 50.56.82.190] ** [out :: 50.56.82.190] Tasks: TOP =&gt; db:migrate ** [out :: 50.56.82.190] (See full trace by running task with --trace) command finished in 5816ms failed: "sh -c 'cd /home/martin/public_html/project/releases/20110905131238; bundle exec rake RAILS_ENV=production db:migrate'" on 50.56.82.190 </code></pre> <p>With a previous deploy I have created a working database on the live server. I created 3 new migrations (due to image upload with new gems carrierwave and rmagick) which I would like to deploy now. Obviously cap deploy:migrations tries to run all migrations from the first one, not just the pending ones.</p> <p>My deploy.rb is:</p> <pre><code>require 'bundler/capistrano' set :application, "otg.in" set :domain, "otg.in" set :user, "martin" set :sudo_use, false set :repository, "git@github.com:Martin118/otg.in.git" set :local_repository, '~/rails_projects/otg.in/.git' set :port, 48000 set :deploy_to, "/home/martin/public_html/#{application}" set :scm, :git set :branch, "master" default_run_options[:pty] = true ssh_options[:forward_agent] = true server "50.56.82.190", :app, :web, :db, :primary =&gt; true after "deploy", "deploy:bundle_gems" after "deploy:bundle_gems", "deploy:restart" after "deploy:update_code", "deploy:migrate" after "deploy", "deploy:cleanup" # Passenger namespace :deploy do task :bundle_gems do run "cd #{deploy_to}/current &amp;&amp; bundle install vendor/gems" end task :start do ; end task :stop do ; end task :restart, :roles =&gt; :app, :except =&gt; { :no_release =&gt; true } do run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}" end end require 'whenever/capistrano' </code></pre> <p>I run rails 3.0.8, cap deploy:check gives me "You appear to have all necessary dependencies installed".</p> <p>Any ideas? Or do you need more information?</p> <p>Thanks for your help!</p> <p>schema.rb on live is:</p> <pre><code>ActiveRecord::Schema.define(:version =&gt; 20110130000344) do create_table "businesses", :force =&gt; true do |t| t.string "business_name" t.string "postal_code" t.string "business_email" t.string "phone" t.string "fax" t.string "web" t.text "description" t.datetime "created_at" t.datetime "updated_at" t.integer "user_id" t.text "address" t.integer "city_id" t.integer "state_id" end create_table "cities", :force =&gt; true do |t| t.string "name" t.datetime "created_at" t.datetime "updated_at" t.integer "state_id" end create_table "states", :force =&gt; true do |t| t.datetime "created_at" t.datetime "updated_at" t.string "name" end create_table "users", :force =&gt; true do |t| t.string "name" t.string "email" t.datetime "created_at" t.datetime "updated_at" t.string "encrypted_password" t.string "salt" t.boolean "admin", :default =&gt; false end add_index "users", ["email"], :name =&gt; "index_users_on_email", :unique =&gt; true end </code></pre> <p>Another update: select * from schema_migrations; on my development database gives me:</p> <p>+----------------+ | version | +----------------+ | 20110112163009 | | 20110113141953 | | 20110113192958 | | 20110114214158 | | 20110115002206 | | 20110119100832 | | 20110120134443 | | 20110127171331 | | 20110127171427 | | 20110127171921 | | 20110127172903 | | 20110127183252 | | 20110129201949 | | 20110129204159 | | 20110129205833 | | 20110130000344 | | 20110808142844 | | 20110809133339 | | 20110809142303 | | 20110809154349 | | 20110810092306 | | 20110810093531 | | 20110812085010 | +----------------+</p> <p>But checking this with MySQL workbench I get (still development database):</p> <p>Error: <code>project_development</code>.<code>schema_migrations</code>: table data is not editable because there is no primary key defined for the table</p> <p>Also, the select * from schema_migrations on the productions database gives me just one migration (the last before I try to update):</p> <p>+----------------+ | version | +----------------+ | 0 | | 20110130000344 | +----------------+</p> <p>Has anyone an idea what happend here?</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload