Class: Migr8::DBMS::MySQL

Inherits:
Base
  • Object
show all
Defined in:
lib/migr8.rb

Defined Under Namespace

Classes: Skeleton

Constant Summary collapse

SYMBOL =
'mysql'
PATTERN =
/\bmysql\b/

Instance Attribute Summary

Attributes inherited from Base

#command, #history_table, #sqltmpfile

Instance Method Summary collapse

Methods inherited from Base

#apply_migrations, #create_history_table, detect_by_command, #fetch_column_value_of, inherited, #initialize, #new_skeleton, #unapply_migrations

Constructor Details

This class inherits a constructor from Migr8::DBMS::Base

Instance Method Details

#execute_sql(sql, cmdopt = nil) ⇒ Object



1124
1125
1126
1127
1128
# File 'lib/migr8.rb', line 1124

def execute_sql(sql, cmdopt=nil)
  preamble = ""
  sql = sql.gsub(/^-----/, '-- --')
  return super(preamble+sql, cmdopt)
end

#get_migrationsObject



1173
1174
1175
1176
# File 'lib/migr8.rb', line 1173

def get_migrations()
  migrations = _get_migrations("-s", /\t/)
  return migrations
end

#history_table_exist?Boolean

Returns:

  • (Boolean)


1167
1168
1169
1170
1171
# File 'lib/migr8.rb', line 1167

def history_table_exist?
  table = history_table()
  output = execute_sql("show tables like '#{table}';")
  return output.include?(table)
end

#q(str) ⇒ Object



1163
1164
1165
# File 'lib/migr8.rb', line 1163

def q(str)
  return str.gsub(/[\\']/, '\\\\\&')
end

#run_sql(sql, opts = {}) ⇒ Object



1130
1131
1132
1133
1134
# File 'lib/migr8.rb', line 1130

def run_sql(sql, opts={})
  preamble = ""
  sql = sql.gsub(/^-----/, '-- --')
  return super(preamble+sql, opts)
end