<commit_before>require 'rails/generators'
require 'rails/generators/migration'
require 'active_record'

module Secondbase
  class MigrationGenerator < Rails::Generators::NamedBase
    include Rails::Generators::Migration

    def self.source_root
      File.join(File.dirname(__FILE__), 'templates')
    end

     # 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(dirname) #:nodoc:
      if ActiveRecord::Base.timestamped_migrations
        Time.now.utc.strftime("%Y%m%d%H%M%S")
      else
        "%.3d" % (current_migration_number(dirname) + 1)
      end
    end

    def create_migration_file
      migration_template 'migration.rb', 
                          "db/migrate/#{SecondBase::CONNECTION_PREFIX}/#{class_name.underscore}.rb", 
                          :assigns => get_local_assigns
    end
    
    private 
    # TODO: We need to add support for name/value pairs like title:string dob:date etc..
    def get_local_assigns
      returning(assigns = {}) do
        assigns[:class_name] = class_name
      end
    end
        
  end
end<commit_msg>in rails 3.1 returning not supported<commit_after>require 'rails/generators'
require 'rails/generators/migration'
require 'active_record'

module Secondbase
  class MigrationGenerator < Rails::Generators::NamedBase
    include Rails::Generators::Migration

    def self.source_root
      File.join(File.dirname(__FILE__), 'templates')
    end

     # 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(dirname) #:nodoc:
      if ActiveRecord::Base.timestamped_migrations
        Time.now.utc.strftime("%Y%m%d%H%M%S")
      else
        "%.3d" % (current_migration_number(dirname) + 1)
      end
    end

    def create_migration_file
      migration_template 'migration.rb', 
                          "db/migrate/#{SecondBase::CONNECTION_PREFIX}/#{class_name.underscore}.rb", 
                          :assigns => get_local_assigns
    end
    
    private 
    # TODO: We need to add support for name/value pairs like title:string dob:date etc..
    def get_local_assigns
      { :class_name => class_name }
    end
        
  end
end
{'fraction_non_alphanumeric': 0.09991708126036485, 'fraction_numerical': 0.0024875621890547263, 'mean_word_length': 2.94281045751634, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5556226', 'n_tokens_mistral': 751, 'n_tokens_neox': 726, 'n_words': 143}