2013-11-18 18:21:15 +04:00
|
|
|
var db = {
|
|
|
|
posts: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false},
|
|
|
|
title: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
2014-01-15 17:29:23 +04:00
|
|
|
markdown: {type: 'text', maxlength: 16777215, fieldtype: 'medium', nullable: true},
|
|
|
|
html: {type: 'text', maxlength: 16777215, fieldtype: 'medium', nullable: true},
|
2013-11-18 18:21:15 +04:00
|
|
|
image: {type: 'text', maxlength: 2000, nullable: true},
|
|
|
|
featured: {type: 'bool', nullable: false, defaultTo: false},
|
|
|
|
page: {type: 'bool', nullable: false, defaultTo: false},
|
|
|
|
status: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'draft'},
|
|
|
|
language: {type: 'string', maxlength: 6, nullable: false, defaultTo: 'en_US'},
|
|
|
|
meta_title: {type: 'string', maxlength: 150, nullable: true},
|
|
|
|
meta_description: {type: 'string', maxlength: 200, nullable: true},
|
|
|
|
author_id: {type: 'integer', nullable: false},
|
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true},
|
|
|
|
published_at: {type: 'dateTime', nullable: true},
|
|
|
|
published_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
users: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false},
|
|
|
|
name: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
|
|
|
slug: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
password: {type: 'string', maxlength: 60, nullable: false},
|
|
|
|
email: {type: 'string', maxlength: 254, nullable: false, unique: true},
|
|
|
|
image: {type: 'text', maxlength: 2000, nullable: true},
|
|
|
|
cover: {type: 'text', maxlength: 2000, nullable: true},
|
|
|
|
bio: {type: 'string', maxlength: 200, nullable: true},
|
|
|
|
website: {type: 'text', maxlength: 2000, nullable: true},
|
|
|
|
location: {type: 'text', maxlength: 65535, nullable: true},
|
|
|
|
accessibility: {type: 'text', maxlength: 65535, nullable: true},
|
|
|
|
status: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'active'},
|
|
|
|
language: {type: 'string', maxlength: 6, nullable: false, defaultTo: 'en_US'},
|
|
|
|
meta_title: {type: 'string', maxlength: 150, nullable: true},
|
|
|
|
meta_description: {type: 'string', maxlength: 200, nullable: true},
|
|
|
|
last_login: {type: 'dateTime', nullable: true},
|
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
roles: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false},
|
|
|
|
name: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
description: {type: 'string', maxlength: 200, nullable: true},
|
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
roles_users: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
role_id: {type: 'integer', nullable: false},
|
|
|
|
user_id: {type: 'integer', nullable: false}
|
|
|
|
},
|
|
|
|
permissions: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false},
|
|
|
|
name: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
object_type: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
action_type: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
object_id: {type: 'integer', nullable: true},
|
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
permissions_users: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
user_id: {type: 'integer', nullable: false},
|
|
|
|
permission_id: {type: 'integer', nullable: false}
|
|
|
|
},
|
|
|
|
permissions_roles: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
role_id: {type: 'integer', nullable: false},
|
|
|
|
permission_id: {type: 'integer', nullable: false}
|
|
|
|
},
|
2013-11-24 18:29:36 +04:00
|
|
|
sessions: {
|
|
|
|
id: {type: 'string', nullable: false, primary: true},
|
|
|
|
expires: {type: 'bigInteger', nullable: false},
|
|
|
|
sess: {type: 'string', maxlength: 4096, nullable: false}
|
|
|
|
},
|
2013-11-18 18:21:15 +04:00
|
|
|
settings: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false},
|
|
|
|
key: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
|
|
|
value: {type: 'text', maxlength: 65535, nullable: true},
|
|
|
|
type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'core'},
|
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
tags: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
uuid: {type: 'string', maxlength: 36, nullable: false},
|
|
|
|
name: {type: 'string', maxlength: 150, nullable: false},
|
|
|
|
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
|
|
|
|
description: {type: 'string', maxlength: 200, nullable: true},
|
|
|
|
parent_id: {type: 'integer', nullable: true},
|
|
|
|
meta_title: {type: 'string', maxlength: 150, nullable: true},
|
|
|
|
meta_description: {type: 'string', maxlength: 200, nullable: true},
|
|
|
|
created_at: {type: 'dateTime', nullable: false},
|
|
|
|
created_by: {type: 'integer', nullable: false},
|
|
|
|
updated_at: {type: 'dateTime', nullable: true},
|
|
|
|
updated_by: {type: 'integer', nullable: true}
|
|
|
|
},
|
|
|
|
posts_tags: {
|
|
|
|
id: {type: 'increments', nullable: false, primary: true},
|
|
|
|
post_id: {type: 'integer', nullable: false, unsigned: true, references: 'id', inTable: 'posts'},
|
|
|
|
tag_id: {type: 'integer', nullable: false, unsigned: true, references: 'id', inTable: 'tags'}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-01-03 04:37:21 +04:00
|
|
|
function isPost(jsonData) {
|
|
|
|
return jsonData.hasOwnProperty('html') && jsonData.hasOwnProperty('markdown')
|
|
|
|
&& jsonData.hasOwnProperty('title') && jsonData.hasOwnProperty('slug');
|
|
|
|
}
|
|
|
|
|
2014-02-13 20:15:29 +04:00
|
|
|
function isTag(jsonData) {
|
|
|
|
return jsonData.hasOwnProperty('name') && jsonData.hasOwnProperty('slug')
|
|
|
|
&& jsonData.hasOwnProperty('description') && jsonData.hasOwnProperty('parent_id');
|
|
|
|
}
|
|
|
|
|
2014-01-03 04:37:21 +04:00
|
|
|
module.exports.tables = db;
|
|
|
|
module.exports.checks = {
|
2014-02-13 20:15:29 +04:00
|
|
|
isPost: isPost,
|
|
|
|
isTag: isTag
|
2014-01-03 04:37:21 +04:00
|
|
|
};
|