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



14
15
16
# File 'lib/sequent/migrations/sql.rb', line 14

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

#sql_file_to_statements(file_location) ⇒ Object



8
9
10
11
12
# File 'lib/sequent/migrations/sql.rb', line 8

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