Migration Broken??

I've created a migration to create a new table. I'm noting that the format of the migration name created by the generator has changed. Up until now, the migration names were of the form "00n_<text>" ... now
the form is <yymmdd><some digits>_<text>.

It's a UTC timestamp

The problem that I'm having is that rake db:migrate is trying to rerun all my migrations from "001" forward. the schema tables in the
database show the schema to be at 19. I would have expected the new migration
to be 020_<text>, but the name format has changed as shown above.

Do you also have a schema migrations table ? if so I'd try dropping
it. This is the replacement for the schema_info table, and should be
automatically created so that migrations are assumed to have run up to
the right point but might have got screwed up.


You could use this script to rename all your migrations with the new format. I've used this chunk of code in a project (undeployed yet) to normalize the migrations names (01_, 02_ ... format and UTC format) Maybe could be useful for you.

#!/usr/bin/env ruby

require 'find' require 'fileutils' require 'optparse'

# Create option parser. options = {} ARGV.options do |opts|   opts.banner << " <path>"   opts.on("-v", "--[no-]verbose", "run verbosely") do |v|     options[:verbose] = v   end

  opts.on("-l", "--[no-]local", "make local changes") do |v|     options[:local] = v   end

  opts.on("-s", "--[no-]subversion", "remane files on subversion") do |v|     options[:subversion] = v   end

  opts.on("-g", "--[no-]git", "remane files on git") do |v|     options[:git] = v   end


path = ARGV[0] or (STDERR.puts ARGV.options; exit 2)

printf "\033[1m\033[33mRename Ruby On Rails Migrations UTC (1 sec) \033[0m\n" printf "\033[1m\033[33mbinoid 09/2008- we make webapps\033[0m\n" sleep(2)

Dir.entries(path).sort.each do |old_name|   if !File.directory?("#{path}/#{old_name}")     new_name = old_name.gsub(/\d+/, Time.now.strftime("%Y%m%d%H%M%S"))

    puts ">> rename #{path + old_name} to #{path + new_name}\n" if options[:verbose]     File.rename(path + old_name, path + new_name) if options[:local]     system( "svn mv #{path + old_name} #{path + new_name}" ) if options[:subversion]     system( "git-rename #{path + old_name} #{path + new_name}" ) if options[:git]     sleep(1)   end end

(Sorry, I don't remember from where I copied this code)

Michael Satterwhite escribió: