0

I have a project with several tables, still in early development stage. I need to make some changes to the migrations and would like to rollback to do it properly. These are minor changes and I would prefer to edit the migrations directly rather than create change migrations.

When I run rake db:rollback I get the following exception:

wrong number of arguments (1 for 0)/Users/mmo/.rvm/gems/ruby-2.2.4/gems/activerecord-4.2.5/lib/active_record/migration.rb:492:in `initialize'

This database is brand new--I've just done rake db:drop db:migrate.

And rake db:migrate:status shows this:

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20151229013054  Create courses
   up     20151229013055  Create races
   up     20151229013326  Create events
   up     20151229013400  Create countries
   up     20151229013424  Create participants
   up     20151229013616  Create efforts
   up     20151229013622  Create locations
   up     20151229013757  Create splits
   up     20151229013938  Create split times
   up     20151229014302  Create users
   up     20160129060100  Create interests
   up     20160131195951  Create ownerships

Gemfile looks like this:

source 'https://rubygems.org'
ruby '2.2.4'
gem 'rails', '4.2.5'
gem 'sqlite3'
gem 'responders', '~> 2.0'
gem 'mysql2', '~> 0.3.18'
gem 'sass-rails', '~> 5.0.4'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'kaminari'
gem 'turbolinks'
group :development, :test do
  gem 'byebug'
end
group :development do
  gem 'web-console', '~> 2.0'
  gem 'spring'
end
gem 'bootstrap-sass'
gem 'high_voltage'
gem 'omniauth'
gem 'omniauth-facebook'
gem 'devise'
gem 'pundit'
gem 'rails_apps_pages'
gem 'therubyracer', :platform=>:ruby
gem 'ar-audit-tracer'
gem 'oj'
gem 'alchemist'
group :development do
  gem 'better_errors'
  gem 'foreman'
  gem 'rails_layout'
end
group :development, :test do
  gem 'pry-rails'
  gem 'pry-rescue'
  gem 'rubocop', '~> 0.36'
  gem 'rspec', '~> 3.4'
  gem 'rspec-rails', '~> 3.0'
end

Any ideas would be most appreciated.

EDIT: Here are the --trace results:

$rake db:migrate --trace
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:schema:dump (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:schema:dump

$rake db:rollback --trace
** Invoke db:rollback (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:rollback

One last thing: I tried rake db:drop db:create and then just ran the first migration (rake db:migrate VERSION=20151229013054). Even then I couldn't rollback that single migration. I get the same error.

moveson
  • 5,103
  • 1
  • 15
  • 32

3 Answers3

0

You have dropped the database and migrated it. You should create one again.

rake db:drop

rake db:create db:migrate

Please go through this answer

Line number 492 in migration.rb,

 <tt>ActiveRecord::Migration::CommandRecorder</tt>.

So you shld create the db again.

Community
  • 1
  • 1
Sravan
  • 18,467
  • 3
  • 30
  • 54
  • I tried rake db:drop then rake db:create and rake db:migrate. I still can't rollback migrations after doing that. – moveson Feb 24 '16 at 22:28
  • Once run this command `rake db:rollback:status` and see whats actually happening in your rollback. – Sravan Feb 25 '16 at 04:57
0

Give them a try serial wise:

rake db:drop :- drops the database for the current env
rake db:create :- creates the database for the current env
rake db:setup :- runs db:schema:load, db:seed
Malware Skiddie
  • 318
  • 2
  • 12
0

I am using the 'ar-audit-tracer' gem for automatic user-stamping of my records. Turns out this gem creates a problem with rake db:rollback. When I comment out the gem, I can rollback just fine. Not sure if this is a general problem or just specific to my case.

moveson
  • 5,103
  • 1
  • 15
  • 32