2013-12-23 04:24:40 +00:00
|
|
|
Promise = require 'bluebird'
|
2014-03-19 19:17:07 +00:00
|
|
|
Knex = require 'knex'
|
2013-12-14 05:18:20 +00:00
|
|
|
|
|
|
|
knex = Knex.initialize(
|
|
|
|
client: 'sqlite3'
|
|
|
|
connection:
|
2014-04-27 21:41:59 +00:00
|
|
|
filename: '/data/database.sqlite'
|
2013-12-14 05:18:20 +00:00
|
|
|
)
|
|
|
|
|
2013-12-23 04:24:40 +00:00
|
|
|
knex.init = Promise.all([
|
2014-03-19 19:17:07 +00:00
|
|
|
knex.schema.hasTable('config')
|
|
|
|
.then (exists) ->
|
2013-12-23 04:24:40 +00:00
|
|
|
if not exists
|
2014-03-19 19:17:07 +00:00
|
|
|
knex.schema.createTable 'config', (t) ->
|
2013-12-23 04:24:40 +00:00
|
|
|
t.string('key').primary()
|
|
|
|
t.string('value')
|
2014-03-19 19:17:07 +00:00
|
|
|
|
|
|
|
knex.schema.hasTable('app')
|
|
|
|
.then (exists) ->
|
2013-12-23 04:24:40 +00:00
|
|
|
if not exists
|
2014-03-19 19:17:07 +00:00
|
|
|
knex.schema.createTable 'app', (t) ->
|
2013-12-23 04:24:40 +00:00
|
|
|
t.increments('id').primary()
|
|
|
|
t.string('name')
|
|
|
|
t.string('containerId')
|
|
|
|
t.string('imageId')
|
|
|
|
t.boolean('privileged')
|
2014-04-03 17:16:37 +00:00
|
|
|
t.json('env')
|
2013-12-23 04:24:40 +00:00
|
|
|
])
|
2013-12-14 05:18:20 +00:00
|
|
|
|
|
|
|
module.exports = knex
|