2013-05-17 01:16:09 +04:00
|
|
|
/*global require, exports */
|
|
|
|
|
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var when = require('when'),
|
2013-05-27 21:24:14 +04:00
|
|
|
knex = require('../../models/base').Knex,
|
2013-05-17 01:16:09 +04:00
|
|
|
fixtures = require('../fixtures/001'),
|
|
|
|
up,
|
|
|
|
down;
|
|
|
|
|
|
|
|
up = function () {
|
|
|
|
|
|
|
|
return when.all([
|
|
|
|
|
|
|
|
knex.Schema.createTable('posts', function (t) {
|
|
|
|
t.increments().primary();
|
|
|
|
t.string('title');
|
|
|
|
t.string('slug');
|
|
|
|
t.text('content');
|
|
|
|
t.text('content_html');
|
|
|
|
t.bool('featured');
|
|
|
|
t.string('image');
|
|
|
|
t.string('status');
|
|
|
|
t.string('language');
|
|
|
|
t.date('created_at');
|
|
|
|
t.integer('created_by');
|
|
|
|
t.date('updated_at');
|
|
|
|
t.integer('updated_by');
|
|
|
|
}),
|
|
|
|
|
|
|
|
knex.Schema.createTable('users', function (t) {
|
|
|
|
t.increments().primary();
|
|
|
|
t.string('username');
|
|
|
|
t.string('first_name');
|
|
|
|
t.string('last_name');
|
2013-05-21 05:03:35 +04:00
|
|
|
t.string('password');
|
2013-05-17 01:16:09 +04:00
|
|
|
t.string('email_address');
|
|
|
|
t.string('profile_picture');
|
|
|
|
t.string('cover_picture');
|
|
|
|
t.text('bio');
|
|
|
|
t.string('url');
|
|
|
|
t.date('created_at');
|
|
|
|
t.integer('created_by');
|
|
|
|
t.date('updated_at');
|
|
|
|
t.integer('updated_by');
|
|
|
|
}),
|
|
|
|
|
|
|
|
knex.Schema.createTable('settings', function (t) {
|
|
|
|
t.increments().primary();
|
|
|
|
t.string('key');
|
|
|
|
t.text('value');
|
|
|
|
t.date('created_at');
|
|
|
|
t.integer('created_by');
|
|
|
|
t.date('updated_at');
|
|
|
|
t.integer('updated_by');
|
|
|
|
})
|
|
|
|
|
|
|
|
// Once we create all of the initial tables, bootstrap any of the data
|
|
|
|
]).then(function () {
|
|
|
|
|
|
|
|
return when.all([
|
|
|
|
knex('posts').insert(fixtures.posts),
|
|
|
|
knex('users').insert(fixtures.users),
|
|
|
|
knex('settings').insert(fixtures.settings)
|
|
|
|
]);
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-05-24 08:02:41 +04:00
|
|
|
down = function () {
|
|
|
|
|
|
|
|
return when.all([
|
|
|
|
knex.Schema.dropTableIfExists("posts"),
|
|
|
|
knex.Schema.dropTableIfExists("users"),
|
|
|
|
knex.Schema.dropTableIfExists("settings")
|
|
|
|
]);
|
|
|
|
};
|
2013-05-17 01:16:09 +04:00
|
|
|
|
|
|
|
exports.up = up;
|
|
|
|
exports.down = down;
|
|
|
|
}());
|