Ghost/core/shared/models/index.js

29 lines
983 B
JavaScript
Raw Normal View History

2013-06-01 18:47:41 +04:00
/*global require, module */
(function () {
"use strict";
var GhostBookshelf = require('./base'),
errors = require('../errorHandling'),
2013-06-01 18:47:41 +04:00
knex = GhostBookshelf.Knex;
module.exports = {
Post: require('./post').Post,
User: require('./user').User,
Role: require('./role').Role,
Permission: require('./permission').Permission,
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();
}, errors.logAndThrowError);
}, errors.logAndThrowError).then(function () {
2013-06-01 18:47:41 +04:00
console.log('models loaded');
}, errors.logAndThrowError);
2013-06-01 18:47:41 +04:00
}
};
}());