Sha256: 685e2a554f48a7f1de4761f2786e08e4ce43b1088fe5a644f03dcd3f81907571

Contents?: true

Size: 756 Bytes

Versions: 11

Compression:

Stored size: 756 Bytes

Contents

require 'rails/generators/migration'

module Popular
  class MigrationGenerator < Rails::Generators::Base
    include Rails::Generators::Migration

    desc "Generates migration for popular (friendships table)"

    def self.orm
      Rails::Generators.options[:rails][:orm]
    end

    def self.source_root
      File.join(File.dirname(__FILE__), 'templates', (orm.to_s unless orm.class.eql?(String)) )
    end

    def self.orm_has_migration?
      [:active_record].include? orm
    end

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

    def create_migration_file
      if self.class.orm_has_migration?
        migration_template 'migration.rb', 'db/migrate/popular_migration'
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
popular-0.7.4 lib/generators/popular/migration/migration_generator.rb
popular-0.7.3 lib/generators/popular/migration/migration_generator.rb
popular-0.7.2 lib/generators/popular/migration/migration_generator.rb
popular-0.7.1 lib/generators/popular/migration/migration_generator.rb
popular-0.7.0 lib/generators/popular/migration/migration_generator.rb
popular-0.6.0 lib/generators/popular/migration/migration_generator.rb
popular-0.5.1 lib/generators/popular/migration/migration_generator.rb
popular-0.5.0 lib/generators/popular/migration/migration_generator.rb
popular-0.4.0 lib/generators/popular/migration/migration_generator.rb
popular-0.3.2 lib/generators/popular/migration/migration_generator.rb
popular-0.3.1 lib/generators/popular/migration/migration_generator.rb