Sha256: 82b22e0c448fc149e2b70883c19dc93b96eab6775b0327598811ba12ae12daba

Contents?: true

Size: 613 Bytes

Versions: 4

Compression:

Stored size: 613 Bytes

Contents

require 'fileutils'
require 'ardb'
require 'ardb/adapter/base'

module Ardb::Adapter

  class Sqlite < Base

    def db_file_path
      File.expand_path(self.database, self.config.root_path)
    end

    def validate!
      if File.exist?(self.db_file_path)
        raise RuntimeError, "`#{self.database}` already exists"
      end
    end

    def create_db
      validate!
      FileUtils.mkdir_p File.dirname(self.db_file_path)
      ActiveRecord::Base.establish_connection(self.connect_hash)
    end

    def drop_db
      FileUtils.rm(self.db_file_path) if File.exist?(self.db_file_path)
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ardb-0.28.3 lib/ardb/adapter/sqlite.rb
ardb-0.28.2 lib/ardb/adapter/sqlite.rb
ardb-0.28.1 lib/ardb/adapter/sqlite.rb
ardb-0.28.0 lib/ardb/adapter/sqlite.rb