Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: ad42aaed04
Fetching contributors…

Cannot retrieve contributors at this time

56 lines (43 sloc) 1.212 kb
module ActiveRecord
module Tasks # :nodoc:
class SQLiteDatabaseTasks # :nodoc:
delegate :connection, :establish_connection, to: ActiveRecord::Base
def initialize(configuration, root = ActiveRecord::Tasks::DatabaseTasks.root)
@configuration, @root = configuration, root
end
def create
raise DatabaseAlreadyExists if File.exist?(configuration['database'])
establish_connection configuration
connection
end
def drop
require 'pathname'
path = Pathname.new configuration['database']
file = path.absolute? ? path.to_s : File.join(root, path)
FileUtils.rm(file) if File.exist?(file)
end
def purge
drop
create
end
def charset
connection.encoding
end
def structure_dump(filename)
dbfile = configuration['database']
`sqlite3 #{dbfile} .schema > #{filename}`
end
def structure_load(filename)
dbfile = configuration['database']
`sqlite3 #{dbfile} < "#{filename}"`
end
private
def configuration
@configuration
end
def root
@root
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.