BadrIT / translation_center

Translation Center is a multi-lingual, GUI rich, community based, translation center for Rails apps
http://www.badrit.com/gems/translation_center/
MIT License
152 stars 71 forks source link

Migration numbers generated are too long #74

Closed zwippie closed 2 years ago

zwippie commented 9 years ago

When the migrations are installed with rails generate translation_center:install, the generated version number for each migration is too long. This will lead to an incorrect schema version in db/schema.rb. The schema version will never be updated for newer migrations that are generated after the migrations for translation_center have been run.

The code that generates the incorrect version number is in translation_center/lib/generators/translation_center/install/install_generator.rb:

def self.next_migration_number(path)
  @migration_number = Time.now.utc.strftime("%Y%m%d%H%M%S%6N").to_i.to_s
end

There a 6 digits too many at the end to be compliant with the usual Rails 4 numbering.

I understand this is to prevent duplicate migration numbers when the method is called three times in succession in a very short time. A poor man's solution would be to sleep 1 second between the generation of each migration. This is not too big of a problem because the task will only be run once on the developers machine.