Sha256: b355151fa9054edc74214829cef2d5174beba8e3be650d10723f477f0255a9dd

Contents?: true

Size: 755 Bytes

Versions: 13

Compression:

Stored size: 755 Bytes

Contents

require 'rails/generators/base'

module PgSearch
  module Migration
    class Generator < Rails::Generators::Base
      Rails::Generators.hide_namespace namespace

      def self.inherited(subclass)
        super
        subclass.source_root File.expand_path('../templates', __FILE__)
      end

      def create_migration
        now = Time.now.utc
        filename = "#{now.strftime('%Y%m%d%H%M%S')}_#{migration_name}.rb"
        template "#{migration_name}.rb.erb", "db/migrate/#{filename}"
      end

      private

      def read_sql_file(filename)
        sql_directory = File.expand_path('../../../../sql', __FILE__)
        source_path = File.join(sql_directory, "#{filename}.sql")
        File.read(source_path).strip
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pg_search-2.0.1 lib/pg_search/migration/generator.rb
pg_search-2.0.0 lib/pg_search/migration/generator.rb
pg_search-1.0.6 lib/pg_search/migration/generator.rb
pg_search-1.0.5 lib/pg_search/migration/generator.rb
pg_search-1.0.4 lib/pg_search/migration/generator.rb
pg_search-1.0.3 lib/pg_search/migration/generator.rb
pg_search-1.0.2 lib/pg_search/migration/generator.rb
pg_search-1.0.1 lib/pg_search/migration/generator.rb
pg_search-1.0.0 lib/pg_search/migration/generator.rb
pg_search-0.7.9 lib/pg_search/migration/generator.rb
pg_search-0.7.8 lib/pg_search/migration/generator.rb
pg_search-0.7.7 lib/pg_search/migration/generator.rb
pg_search-0.7.6 lib/pg_search/migration/generator.rb