Sha256: 03199f445aa354dc03fb5f2ea64b92e38cae5a755c226f4c6f6e4af0a7bed6cd

Contents?: true

Size: 833 Bytes

Versions: 3

Compression:

Stored size: 833 Bytes

Contents

require 'rails/generators/migration'

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

    source_root File.expand_path('../templates', __FILE__)

    def create_migration_file
      migration_template "migration.rb", "db/migrate/create_#{file_name}_fulltext_index.rb"
    end

    def fulltext_fields
      eval(name).fulltext_config.fields
    end

    # Define the next_migration_number method (necessary for the migration_template method to work)
    def self.next_migration_number(dirname)
      if ActiveRecord::Base.timestamped_migrations
        sleep 1 # make sure each time we get a different timestamp
        Time.new.utc.strftime("%Y%m%d%H%M%S")
      else
        "%.3d" % (current_migration_number(dirname) + 1)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mysql_simple_fulltext-0.0.3 lib/generators/mysql_simple_fulltext/migration_generator.rb
mysql_simple_fulltext-0.0.2 lib/generators/mysql_simple_fulltext/migration_generator.rb
mysql_simple_fulltext-0.0.1 lib/generators/mysql_simple_fulltext/migration_generator.rb