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