lib/ring/sqa/database.rb in ring-sqa-0.3.1 vs lib/ring/sqa/database.rb in ring-sqa-0.4.1
- old
+ new
@@ -41,20 +41,30 @@
end
private
def initialize
- Sequel::Model.plugin :schema
sequel_opts = { max_connections: 1, pool_timout: 60 }
if CFG.ram_database?
@db = Sequel.sqlite sequel_opts
else
file = '%s.db' % CFG.afi
file = File.join CFG.directory, file
File.unlink file rescue nil # delete old database
@db = Sequel.sqlite file, sequel_opts
end
+ create_db
require_relative 'database/model.rb'
+ end
+
+ def create_db
+ @db.create_table?(:pings) do
+ primary_key :id
+ Fixnum :time
+ String :peer
+ Fixnum :latency
+ String :result
+ end
end
end
end
end