class Migrate::Lang::Sql

Public Class Methods

new(db) click to toggle source
# File lib/migrate/lang/sql.rb, line 4
def initialize(db)
  @db = db
  @ext = "sql"
end

Public Instance Methods

create_migration(dir) click to toggle source
# File lib/migrate/lang/sql.rb, line 9
def create_migration(dir)
  File.open("#{dir}/up.#{@ext}", "w") do |f|
    f.puts "-- Here goes SQL for migration forward\n"
  end

  File.open("#{dir}/down.#{@ext}", "w") do |f|
    f.puts "-- Here goes SQL for migration backward\n"
  end
end
exec_migration(dir, is_up) click to toggle source
# File lib/migrate/lang/sql.rb, line 19
def exec_migration(dir, is_up)
  script = "#{dir}/#{is_up ? "up" : "down"}.#{@ext}"
  Log.info("Executing #{script}...")
  @db.exec_sql(File.read(script))
end