Module: Photostat::DB

Defined in:
lib/photostat/db/base.rb

Class Method Summary collapse

Class Method Details

.instanceObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/photostat/db/base.rb', line 7

def self.instance
  unless @DB
    config = Photostat.config
    system = File.join(config[:repository_path], 'system')
    Dir.mkdir system unless File.directory? system

    path = File.join(system, 'photostat.db')
    @DB = Sequel.sqlite(path)
  end
  return @DB
end

.migrate!Object



19
20
21
22
23
# File 'lib/photostat/db/base.rb', line 19

def self.migrate!
  db = self.instance
  Sequel.extension :migration
  Sequel::Migrator.apply(db, File.dirname(__FILE__))
end