Sha256: 18072f75f8b982a15e2806f0eef694ad5ffaa9753dd85b6cce1f9d9aecc95f5d
Contents?: true
Size: 1.04 KB
Versions: 3
Compression:
Stored size: 1.04 KB
Contents
# -*- encoding : utf-8 -*- require 'rails/generators' require 'rails/generators/migration' class Sufia::Models::AbstractMigrationGenerator < Rails::Generators::Base include Rails::Generators::Migration # Implement the required interface for Rails::Generators::Migration. # taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb def self.next_migration_number(path) if @prev_migration_nr @prev_migration_nr += 1 else last_migration = Dir[File.join(path, '*.rb')].sort.last @prev_migration_nr = if last_migration last_migration.sub(File.join(path, '/'), '').to_i + 1 else Time.now.utc.strftime("%Y%m%d%H%M%S").to_i end end @prev_migration_nr.to_s end protected def better_migration_template(file) migration_template "migrations/#{file}", "db/migrate/#{file}" rescue Rails::Generators::Error => e say_status("error", e.message, :red) end end
Version data entries
3 entries across 3 versions & 1 rubygems