fix: makes sure unique and sequential date

main
Washington Botelho 2018-02-08 18:49:45 -02:00
parent 214223750b
commit 9de85d0814
No known key found for this signature in database
GPG Key ID: 5DE4F42A8F073617
1 changed files with 8 additions and 4 deletions

View File

@ -7,14 +7,18 @@ module Rating
desc 'creates Rating migration'
def create_migration
template 'db/migrate/create_rating_table.rb', "db/migrate/#{timestamp}_create_rating_table.rb"
template 'db/migrate/create_rate_table.rb', "db/migrate/#{timestamp}_create_rate_table.rb"
template 'db/migrate/create_rating_table.rb', "db/migrate/#{timestamp(0)}_create_rating_table.rb"
template 'db/migrate/create_rate_table.rb', "db/migrate/#{timestamp(1)}_create_rate_table.rb"
end
private
def timestamp
Time.current.strftime '%Y%m%d%H%M%S'
def time
@time ||= Time.current
end
def timestamp(seconds)
(time + seconds.seconds).strftime '%Y%m%d%H%M%S'
end
end
end