Module: Sequent::Migrations::Sql

Included in:
Executor, ViewSchema
Defined in:
lib/sequent/migrations/sql.rb

Instance Method Summary collapse

Instance Method Details

#exec_sql(sql) ⇒ Object



12
13
14
# File 'lib/sequent/migrations/sql.rb', line 12

def exec_sql(sql)
  Sequent::ApplicationRecord.connection.execute(sql)
end

#sql_file_to_statements(file_location) ⇒ Object



6
7
8
9
10
# File 'lib/sequent/migrations/sql.rb', line 6

def sql_file_to_statements(file_location)
  sql_string = File.read(file_location, encoding: 'bom|utf-8')
  sql_string = yield(sql_string) if block_given?
  sql_string.split(/;$/).reject { |statement| statement.remove("\n").blank? }
end