Sha256: d7b1efdfdd9239869b6adafc75a13de34e115b37234da3a8757f410dc853197d

Contents?: true

Size: 804 Bytes

Versions: 6

Compression:

Stored size: 804 Bytes

Contents

# frozen_string_literal: true

# require "rails/generators/base"

module Polysearch
  module Generators
    class MigrationGenerator < Rails::Generators::Base
      desc "Copy polysearch database migrations into your project"
      argument :searchable_id_datatype, type: :string, default: "bigint"
      source_root File.expand_path("../templates", __FILE__)

      def copy_polysearch_migration
        template "migration.rb", "db/migrate/#{timestamp}_add_polysearch.rb",
          searchable_id_datatype: searchable_id_datatype,
          migration_version: migration_version
      end

      private

      def timestamp
        DateTime.current.strftime "%Y%m%d%H%M%S"
      end

      def migration_version
        "[#{Rails::VERSION::MAJOR}.#{Rails::VERSION::MINOR}]"
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
polysearch-0.2.4 lib/generators/polysearch/migration_generator.rb
polysearch-0.2.3 lib/generators/polysearch/migration_generator.rb
polysearch-0.2.1 lib/generators/polysearch/migration_generator.rb
polysearch-0.2.0 lib/generators/polysearch/migration_generator.rb
polysearch-0.1.1 lib/generators/polysearch/migration_generator.rb
polysearch-0.1.0 lib/generators/polysearch/migration_generator.rb