2013-06-01 18:47:41 +04:00
|
|
|
/*global require, module */
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var GhostBookshelf = require('./base'),
|
2013-06-17 01:36:28 +04:00
|
|
|
errors = require('../errorHandling'),
|
2013-06-01 18:47:41 +04:00
|
|
|
knex = GhostBookshelf.Knex;
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
Post: require('./post').Post,
|
|
|
|
User: require('./user').User,
|
2013-06-05 07:47:11 +04:00
|
|
|
Role: require('./role').Role,
|
|
|
|
Permission: require('./permission').Permission,
|
2013-06-08 09:03:55 +04:00
|
|
|
Settings: require('./settings').Settings,
|
2013-06-01 18:47:41 +04:00
|
|
|
init: function () {
|
|
|
|
return knex.Schema.hasTable('posts').then(null, function () {
|
|
|
|
// Simple bootstraping of the data model for now.
|
|
|
|
var migration = require('../data/migration/001');
|
|
|
|
return migration.down().then(function () {
|
|
|
|
return migration.up();
|
2013-06-17 01:36:28 +04:00
|
|
|
}, errors.logAndThrowError);
|
|
|
|
}, errors.logAndThrowError).then(function () {
|
2013-06-01 18:47:41 +04:00
|
|
|
console.log('models loaded');
|
2013-06-17 01:36:28 +04:00
|
|
|
}, errors.logAndThrowError);
|
2013-06-01 18:47:41 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}());
|