Class: Textacular::TrigramInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/textacular/trigram_installer.rb

Instance Method Summary collapse

Instance Method Details

#generate_migrationObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/textacular/trigram_installer.rb', line 2

def generate_migration
  content = <<-MIGRATION
class InstallTrigram < ActiveRecord::Migration[5.0]
def self.up
  ActiveRecord::Base.connection.execute("CREATE EXTENSION IF NOT EXISTS pg_trgm;")
end

def self.down
  ActiveRecord::Base.connection.execute("DROP EXTENSION pg_trgm;")
end
end
MIGRATION
  filename = "install_trigram"
  generator = Textacular::MigrationGenerator.new(filename, content)
  generator.generate_migration
end