Sha256: fc514d16badef9bd0c919119ed3248cfcfbba2411e5c1ec9f63bba0cf8b6a720
Contents?: true
Size: 990 Bytes
Versions: 1
Compression:
Stored size: 990 Bytes
Contents
require 'active_record' 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', __dir__) 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}", migration_version end private def read_sql_file(filename) sql_directory = File.expand_path('../../../sql', __dir__) source_path = File.join(sql_directory, "#{filename}.sql") File.read(source_path).strip end def migration_version if ActiveRecord::VERSION::MAJOR >= 5 "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" else "" end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pg_search-2.1.3 | lib/pg_search/migration/generator.rb |