Module: NoWhen::Model

Defined in:
lib/nowhen/model.rb,
lib/nowhen/model/log.rb,
lib/nowhen/model/tag.rb

Defined Under Namespace

Classes: Log, Tag

Class Method Summary collapse

Class Method Details

.init(db_path) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/nowhen/model.rb', line 9

def self.init(db_path)
  FileUtils.mkdir_p File.dirname(db_path) unless File.exists? File.dirname(db_path)
  DataMapper.setup(:default, {:adapter => :sqlite, :database => db_path})
  DataMapper::Logger.new($stdout, :debug)
  migrate unless File.exists? db_path
  DataMapper.finalize
end

.migrateObject



17
18
19
20
# File 'lib/nowhen/model.rb', line 17

def self.migrate
  require 'dm-migrations'
  DataMapper.auto_migrate!
end

.upgradeObject



22
23
24
25
# File 'lib/nowhen/model.rb', line 22

def self.upgrade
  require 'dm-migrations'
  DataMapper.auto_upgrade!
end