Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Multiple migrations have the version number #1

Merged
merged 1 commit into from

2 participants

@NikoRoberts
$ bundle exec rake db:migraterake aborted!
Multiple migrations have the version number 20120406141821
$ ls db/migrate/20120406141821_create_manybots_github_
20120406141821_create_manybots_github_commits.manybots_github.rb
20120406141821_create_manybots_github_repositories.manybots_github.rb

From manybots-github / lib / generators / manybots_github / install_generator.rb

There was this method

def self.next_migration_number(path)
   Time.now.utc.strftime("%Y%m%d%H%M%S")
end

This is not sufficient as the two migration files for Github commits and repositories get generated in the same second so I updated it to check the migration number is the path passed in the parameter

@webcracy webcracy merged commit 7740009 into manybots:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 6, 2012
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 2 deletions.
  1. +7 −2 lib/generators/manybots_github/install_generator.rb
View
9 lib/generators/manybots_github/install_generator.rb
@@ -13,8 +13,13 @@ class InstallGenerator < Rails::Generators::Base
class_option :routes, :desc => "Generate routes", :type => :boolean, :default => true
class_option :migrations, :desc => "Generate migrations", :type => :boolean, :default => true
- def self.next_migration_number(path)
- Time.now.utc.strftime("%Y%m%d%H%M%S")
+ def self.next_migration_number(dirname) #:nodoc:
+ next_migration_number = current_migration_number(dirname) + 1
+ if ActiveRecord::Base.timestamped_migrations
+ [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
+ else
+ "%.3d" % next_migration_number
+ end
end
desc 'Mounts Github Observer at "/manybots-github"'
Something went wrong with that request. Please try again.