rake db:migrate issue 'No migration with version number 3'

First, I'm new to 'Ruby on Rails', but have 33 years experience in
programming (mainframe, unix, windows, you name it, I've programed on
it). Also, before I put this together I did read all of the threads out
there which mention the 'rake' error.

I have to say, the responses to these poor people were pretty
non-informational. let's try to do better here... Please???

I'm using:
Windows XP rev3
Ruby - 1.8.6
Rails - 2.3.2
Rake - 0.8.7
mysql - 5.0.51a
Also, I'm running everything via the Windows command line.

I have two files in the db/migrate director:
20090715120000_create_entries.rb
20090715150000_create_people.rb

When I first got this error, I have only the first of the two files
(the create_entries.rb). SO, rather then argue with the system I simply
renamed the file to '003_create_entries.rb' and, low and behold, that
worked. I got the 'entries' table created.

Next I wanted the table 'people' created
(20090715150000_create_people.rb) and, the rake db:migrate could not
find it. I tried changing the name to '010_create_people.rb' and
rerunning the 'rake db:migrate'. I did not seem to notice that file at
all and, of course, no table created.

SO, I changed the file names back to the original names, and went into
the database and change the schema_migration.version to
'20090715120000'. When I ran the 'rake db:migrate' command we're back
to the original error.

I then tried to clear the *(&^* schema_migration table and rename the
files to:
001_create_entries.rb
003_create_people.rb
and reran the rake command.... it argued with me about 'entries' already
existing, so I dropped 'entries' and ran it again.... Success....

WTF???

Apparently rake is confused about what version of the versioning it is
processing or something. I've tried upgradding everything, no joy.

The trace from rake with:
20090715120000_create_entries.rb
20090715150000_create_people.rb
and schema_migration.version to '20090715120000'

Start Trace:***************************
C:\xampp\ruby\guestbook>rake db:migrate --trace
(in C:/xampp/ruby/guestbook)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
No migration with version number 3
C:/xampp/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/migrat
ion.rb:462:in `migrate'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/migrat
ion.rb:404:in `down'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/migrat
ion.rb:384:in `migrate'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/tasks/databases.rake:116
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
`call'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
`execute'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
`each'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
`execute'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
`invoke_with_
call_chain'
C:/xampp/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
`invoke_with_
call_chain'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in
`invoke'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
`invoke_task
'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
`top_level'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
`each'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
`top_level'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_ex
ception_handling'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in
`top_level'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in
`run'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_ex
ception_handling'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in
`run'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
C:/xampp/ruby/bin/rake:19:in `load'
C:/xampp/ruby/bin/rake:19

Development log:************************
  e[4;36;1mSQL (0.0ms)e[0m e[0;1mSHOW TABLESe[0m
  e[4;35;1mSQL (0.0ms)e[0m e[0mSELECT version FROM
schema_migrationse[0m
  e[4;36;1mSQL (0.0ms)e[0m e[0;1mSET NAMES 'utf8'e[0m
  e[4;35;1mSQL (0.0ms)e[0m e[0mSET SQL_AUTO_IS_NULL=0e[0m
  e[4;36;1mSQL (0.0ms)e[0m e[0;1mSHOW TABLESe[0m
  e[4;35;1mSQL (16.0ms)e[0m e[0mSELECT version FROM
schema_migrationse[0m
  e[4;36;1mSQL (0.0ms)e[0m e[0;1mSHOW TABLESe[0m
  e[4;35;1mSQL (0.0ms)e[0m e[0mSELECT version FROM
schema_migrationse[0m

Have you fiddled with the setting of
config.active_record.timestamped_migrations in environment.rb? This
specifies whether to use timestamped or incrementing integer indexes
for the migrations.

Colin

Colin Law wrote:

Have you fiddled with the setting of
config.active_record.timestamped_migrations in environment.rb? This
specifies whether to use timestamped or incrementing integer indexes
for the migrations.

Colin

Colin, thanks for the reply. The 'environment.rb' file is vanilla:

# Be sure to restart your server when you modify this file

# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
  # Settings in config/environments/* take precedence over those
specified here.
  # Application configuration should go into files in
config/initializers
  # -- all .rb files in that directory are automatically loaded.

  # Add additional load paths for your own custom dirs
  # config.load_paths += %W( #{RAILS_ROOT}/extras )

  # Specify gems that this application depends on and have them
installed with rake gems:install
  # config.gem "bj"
  # config.gem "hpricot", :version => '0.6', :source =>
"http://code.whytheluckystiff.net"
  # config.gem "sqlite3-ruby", :lib => "sqlite3"
  # config.gem "aws-s3", :lib => "aws/s3"

  # Only load the plugins named here, in the order given (default is
alphabetical).
  # :all can be used as a placeholder for all plugins not explicitly
named
  # config.plugins = [ :exception_notification, :ssl_requirement, :all ]

  # Skip frameworks you're not going to use. To use Rails without a
database,
  # you must remove the Active Record framework.
  # config.frameworks -= [ :active_record, :active_resource,
:action_mailer ]

  # Activate observers that should always be running
  # config.active_record.observers = :cacher, :garbage_collector,
:forum_observer

  # Set Time.zone default to the specified zone and make Active Record
auto-convert to this zone.
  # Run "rake -D time" for a list of tasks for finding time zone names.
  config.time_zone = 'UTC'

  # The default locale is :en and all translations from
config/locales/*.rb,yml are auto loaded.
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales',
'*.{rb,yml}')]
  # config.i18n.default_locale = :de
end

Is this a new application made with Rails 2.3.2 or did you start with
an earlier version of Rails?

Colin

Colin Law wrote:

Is this a new application made with Rails 2.3.2 or did you start with
an earlier version of Rails?

I started this application on 7/14. Havn't done an upgrade since then.

I have run out of ideas - anyone else?
Carl you might need to re-state the original problem since one of us
seems to have snipped it.

Colin

Colin Law wrote:

Can you paste the trace you get when trying db:migrate for the first
time in a new application?

Well, I started a completely new application and I built two models
using the 'script/generate scaffold' and am still having the problem.

Version/Environment is still:
Windows XP rev3
Ruby - 1.8.6
Rails - 2.3.2
Rake - 0.8.7
mysql - 5.0.51a
Also, I'm running everything via the Windows command line.

Why would this version of Rake be attempting to use the &*^%& version
numbers and not the version timestamps? Any ideas?

if there is an environment variable called VERSION then rails tries to
migrate to that version (this is largely because until recently rake
didn't allow you to pass arguments to tasks so it's faked up with
environment variables eg rake db:migrate FOO=123 )

Unfortunately VERSION is quite a non specific word and occasionally
you may find that other software has set that environment variable, in
this particular case to 3. Rails thinks you are telling it "migrate to
version 3" and is complaining because it couldn't find that file.
Running db:migrate again after you added the second migration did
nothing because rails still thinks you're saying 'i want to migrate to
version 3'.

Fred

Andrés Cirugeda Esco wrote:

Can you paste the trace you get when trying db:migrate for the first
time in a new application?
--
Andr�s Cirugeda Esco
ASPgems
Email: andres at aspgems dot com

'All we have to decide is what to do with the time that is given to us'.
--Gandalf.

El 19/07/2009, a las 22:56, Carl Franz
escribi�:

Carlos, here you are:

The two files available for migration are:
07/19/2009 03:44 PM 354 20090719204452_create_students.rb
07/19/2009 03:45 PM 246 20090719204535_create_awards.rb

The following is the trace:

C:\xampp\ruby\student>rake db:migrate
(in C:/xampp/ruby/student)
rake aborted!
No migration with version number 3

(See full trace by running task with --trace)

C:\xampp\ruby\student>rake db:migrate --trace
(in C:/xampp/ruby/student)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
rake aborted!
No migration with version number 3
C:/xampp/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/migrat
ion.rb:462:in `migrate'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/migrat
ion.rb:400:in `up'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/migrat
ion.rb:385:in `migrate'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/tasks/databases.rake:116
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
`call'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
`execute'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
`each'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
`execute'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
`invoke_with_
call_chain'
C:/xampp/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
`invoke_with_
call_chain'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in
`invoke'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
`invoke_task
'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
`top_level'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
`each'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
`top_level'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_ex
ception_handling'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in
`top_level'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in
`run'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
`standard_ex
ception_handling'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in
`run'
C:/xampp/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
C:/xampp/ruby/bin/rake:19:in `load'
C:/xampp/ruby/bin/rake:19

Frederick Cheung wrote:

Thany you Fred, now that I understand, that appears to be what it is
doing. Is there any relatively simple way to disable this behaviour in
'migrate'?

not without changing the rails sourcecode. easiest way is probably to
unset that environment variable or overwrite it with an empty string.

Fred

Frederick Cheung wrote: