2019-04-08 13:01:22 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var path = require('path');
|
|
|
|
var sync = require('../sync.js');
|
|
|
|
|
2019-05-09 06:35:02 +00:00
|
|
|
module.exports = function (sequelize) {
|
2019-04-08 13:01:22 +00:00
|
|
|
var db = {};
|
|
|
|
|
2019-05-09 06:35:02 +00:00
|
|
|
[ 'keypair.js'
|
|
|
|
, 'domain.js'
|
|
|
|
, 'certificate.js'
|
|
|
|
, 'chain.js'
|
|
|
|
].forEach(function (file) {
|
|
|
|
var model = sequelize['import'](path.join(__dirname, file));
|
2019-04-10 14:11:38 +00:00
|
|
|
db[model.name] = model;
|
|
|
|
});
|
2019-04-08 13:01:22 +00:00
|
|
|
|
|
|
|
Object.keys(db).forEach(function (modelName) {
|
2019-05-09 06:35:02 +00:00
|
|
|
db[modelName].associate(db);
|
2019-04-08 13:01:22 +00:00
|
|
|
});
|
|
|
|
|
2019-05-09 06:35:02 +00:00
|
|
|
return sync(db).then(function () {
|
|
|
|
return db;
|
|
|
|
});
|
2019-04-08 13:01:22 +00:00
|
|
|
};
|