0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Merge pull request #6388 from ErisDS/schema-rejig

Reorganise & Rename server/data/ folder internals
This commit is contained in:
Sebastian Gierlinger 2016-02-08 11:19:40 +01:00
commit 819116465e
22 changed files with 286 additions and 278 deletions

View file

@ -1,8 +1,8 @@
var _ = require('lodash'),
Promise = require('bluebird'),
versioning = require('../versioning'),
config = require('../../config'),
utils = require('../utils'),
commands = require('../schema').commands,
versioning = require('../schema').versioning,
serverUtils = require('../../utils'),
errors = require('../../errors'),
settings = require('../../api/settings'),
@ -28,7 +28,7 @@ exportFileName = function () {
};
exporter = function () {
return Promise.join(versioning.getDatabaseVersion(), utils.getTables()).then(function (results) {
return Promise.join(versioning.getDatabaseVersion(), commands.getTables()).then(function (results) {
var version = results[0],
tables = results[1],
selectOps = _.map(tables, function (name) {

View file

@ -1,6 +1,6 @@
var _ = require('lodash'),
var _ = require('lodash'),
errors = require('../../errors'),
utils = require('../utils'),
commands = require('../schema').commands,
schema = require('../schema').tables,
i18n = require('../../i18n'),
@ -22,7 +22,7 @@ getDeleteCommands = function getDeleteCommands(oldTables, newTables) {
return _.map(deleteTables, function (table) {
return function () {
logInfo(i18n.t('notices.data.migration.commands.deletingTable', {table: table}));
return utils.deleteTable(table);
return commands.deleteTable(table);
};
});
};
@ -31,7 +31,7 @@ getAddCommands = function getAddCommands(oldTables, newTables) {
return _.map(addTables, function (table) {
return function () {
logInfo(i18n.t('notices.data.migration.commands.creatingTable', {table: table}));
return utils.createTable(table);
return commands.createTable(table);
};
});
};
@ -42,7 +42,7 @@ addColumnCommands = function addColumnCommands(table, columns) {
return _.map(addColumns, function (column) {
return function () {
logInfo(i18n.t('notices.data.migration.commands.addingColumn', {table: table, column: column}));
return utils.addColumn(table, column);
return commands.addColumn(table, column);
};
});
};
@ -53,14 +53,14 @@ modifyUniqueCommands = function modifyUniqueCommands(table, indexes) {
if (!_.contains(indexes, table + '_' + column + '_unique')) {
return function () {
logInfo(i18n.t('notices.data.migration.commands.addingUnique', {table: table, column: column}));
return utils.addUnique(table, column);
return commands.addUnique(table, column);
};
}
} else if (!schema[table][column].unique) {
if (_.contains(indexes, table + '_' + column + '_unique')) {
return function () {
logInfo(i18n.t('notices.data.migration.commands.droppingUnique', {table: table, column: column}));
return utils.dropUnique(table, column);
return commands.dropUnique(table, column);
};
}
}

View file

@ -5,18 +5,18 @@
// rather than abstracted into a migration system. The upgrade function checks that its changes are safe before
// making them.
var Promise = require('bluebird'),
crypto = require('crypto'),
sequence = require('../../utils/sequence'),
_ = require('lodash'),
errors = require('../../errors'),
config = require('../../config'),
utils = require('../../utils'),
models = require('../../models'),
fixtures = require('./fixtures'),
permissions = require('./permissions'),
notifications = require('../../api/notifications'),
i18n = require('../../i18n'),
var Promise = require('bluebird'),
crypto = require('crypto'),
_ = require('lodash'),
fixtures = require('./fixtures'),
permissions = require('./permissions/index'),
notifications = require('../../../api/notifications'),
config = require('../../../config'),
errors = require('../../../errors'),
i18n = require('../../../i18n'),
models = require('../../../models'),
utils = require('../../../utils'),
sequence = require('../../../utils/sequence'),
// Private
logInfo,

View file

@ -1,12 +1,12 @@
// # Permissions Fixtures
// Sets up the permissions, and the default permissions_roles relationships
var Promise = require('bluebird'),
sequence = require('../../../utils/sequence'),
_ = require('lodash'),
errors = require('../../../errors'),
models = require('../../../models'),
errors = require('../../../../errors'),
i18n = require('../../../../i18n'),
models = require('../../../../models'),
sequence = require('../../../../utils/sequence'),
fixtures = require('./permissions'),
i18n = require('../../../i18n'),
// private
logInfo,

View file

@ -1,19 +1,19 @@
var _ = require('lodash'),
Promise = require('bluebird'),
crypto = require('crypto'),
sequence = require('../../utils/sequence'),
path = require('path'),
fs = require('fs'),
errors = require('../../errors'),
commands = require('./commands'),
versioning = require('../versioning'),
models = require('../../models'),
fixtures = require('../fixtures'),
builder = require('./builder'),
fixtures = require('./fixtures'),
schema = require('../schema').tables,
commands = require('../schema').commands,
versioning = require('../schema').versioning,
dataExport = require('../export'),
utils = require('../utils'),
config = require('../../config'),
errors = require('../../errors'),
i18n = require('../../i18n'),
models = require('../../models'),
sequence = require('../../utils/sequence'),
schemaTables = _.keys(schema),
@ -125,7 +125,7 @@ init = function (tablesOnly) {
reset = function () {
var tables = _.map(schemaTables, function (table) {
return function () {
return utils.deleteTable(table);
return commands.deleteTable(table);
};
}).reverse();
@ -138,7 +138,7 @@ migrateUpFreshDb = function (tablesOnly) {
tables = _.map(schemaTables, function (table) {
return function () {
logInfo(i18n.t('notices.data.migration.index.creatingTable', {table: table}));
return utils.createTable(table);
return commands.createTable(table);
};
});
logInfo(i18n.t('notices.data.migration.index.creatingTables'));
@ -162,27 +162,27 @@ migrateUp = function (fromVersion, toVersion) {
migrateOps = [];
return backupDatabase().then(function () {
return utils.getTables();
return commands.getTables();
}).then(function (tables) {
oldTables = tables;
if (!_.isEmpty(oldTables)) {
return utils.checkTables();
return commands.checkTables();
}
}).then(function () {
migrateOps = migrateOps.concat(commands.getDeleteCommands(oldTables, schemaTables));
migrateOps = migrateOps.concat(commands.getAddCommands(oldTables, schemaTables));
migrateOps = migrateOps.concat(builder.getDeleteCommands(oldTables, schemaTables));
migrateOps = migrateOps.concat(builder.getAddCommands(oldTables, schemaTables));
return Promise.all(
_.map(oldTables, function (table) {
return utils.getIndexes(table).then(function (indexes) {
modifyUniCommands = modifyUniCommands.concat(commands.modifyUniqueCommands(table, indexes));
return commands.getIndexes(table).then(function (indexes) {
modifyUniCommands = modifyUniCommands.concat(builder.modifyUniqueCommands(table, indexes));
});
})
);
}).then(function () {
return Promise.all(
_.map(oldTables, function (table) {
return utils.getColumns(table).then(function (columns) {
migrateOps = migrateOps.concat(commands.addColumnCommands(table, columns));
return commands.getColumns(table).then(function (columns) {
migrateOps = migrateOps.concat(builder.addColumnCommands(table, columns));
});
})
);

View file

@ -1,225 +0,0 @@
var db = {
posts: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
title: {type: 'string', maxlength: 150, nullable: false},
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
markdown: {type: 'text', maxlength: 16777215, fieldtype: 'medium', nullable: true},
html: {type: 'text', maxlength: 16777215, fieldtype: 'medium', nullable: true},
image: {type: 'text', maxlength: 2000, nullable: true},
featured: {type: 'bool', nullable: false, defaultTo: false, validations: {isIn: [[0, 1, false, true]]}},
page: {type: 'bool', nullable: false, defaultTo: false, validations: {isIn: [[0, 1, false, true]]}},
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, validations: {isUUID: true}},
name: {type: 'string', maxlength: 150, nullable: false},
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
password: {type: 'string', maxlength: 60, nullable: false},
email: {type: 'string', maxlength: 254, nullable: false, unique: true, validations: {isEmail: 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, validations: {isEmptyOrURL: 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},
tour: {type: 'text', maxlength: 65535, 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, validations: {isUUID: true}},
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, validations: {isUUID: true}},
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}
},
permissions_apps: {
id: {type: 'increments', nullable: false, primary: true},
app_id: {type: 'integer', nullable: false},
permission_id: {type: 'integer', nullable: false}
},
settings: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
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', validations: {isIn: [['core', 'blog', 'theme', 'app', 'plugin', 'private']]}},
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, validations: {isUUID: true}},
name: {type: 'string', maxlength: 150, nullable: false, validations: {matches: /^([^,]|$)/}},
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
description: {type: 'string', maxlength: 200, nullable: true},
image: {type: 'text', maxlength: 2000, nullable: true},
hidden: {type: 'bool', nullable: false, defaultTo: false, validations: {isIn: [[0, 1, false, 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: 'posts.id'},
tag_id: {type: 'integer', nullable: false, unsigned: true, references: 'tags.id'},
sort_order: {type: 'integer', nullable: false, unsigned: true, defaultTo: 0}
},
apps: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
name: {type: 'string', maxlength: 150, nullable: false, unique: true},
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
version: {type: 'string', maxlength: 150, nullable: false},
status: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'inactive'},
created_at: {type: 'dateTime', nullable: false},
created_by: {type: 'integer', nullable: false},
updated_at: {type: 'dateTime', nullable: true},
updated_by: {type: 'integer', nullable: true}
},
app_settings: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
key: {type: 'string', maxlength: 150, nullable: false, unique: true},
value: {type: 'text', maxlength: 65535, nullable: true},
app_id: {type: 'integer', nullable: false, unsigned: true, references: 'apps.id'},
created_at: {type: 'dateTime', nullable: false},
created_by: {type: 'integer', nullable: false},
updated_at: {type: 'dateTime', nullable: true},
updated_by: {type: 'integer', nullable: true}
},
app_fields: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
key: {type: 'string', maxlength: 150, nullable: false},
value: {type: 'text', maxlength: 65535, nullable: true},
type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'html'},
app_id: {type: 'integer', nullable: false, unsigned: true, references: 'apps.id'},
relatable_id: {type: 'integer', nullable: false, unsigned: true},
relatable_type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'posts'},
active: {type: 'bool', nullable: false, defaultTo: true, validations: {isIn: [[0, 1, false, 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}
},
clients: {
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, unique: true},
secret: {type: 'string', maxlength: 150, nullable: false},
redirection_uri: {type: 'string', maxlength: 2000, nullable: true},
logo: {type: 'string', maxlength: 2000, nullable: true},
status: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'development'},
type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'ua'},
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}
},
client_trusted_domains: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false},
client_id: {type: 'integer', nullable: false, unsigned: true, references: 'clients.id'},
trusted_domain: {type: 'string', maxlength: 2000, nullable: true}
},
accesstokens: {
id: {type: 'increments', nullable: false, primary: true},
token: {type: 'string', nullable: false, unique: true},
user_id: {type: 'integer', nullable: false, unsigned: true, references: 'users.id'},
client_id: {type: 'integer', nullable: false, unsigned: true, references: 'clients.id'},
expires: {type: 'bigInteger', nullable: false}
},
refreshtokens: {
id: {type: 'increments', nullable: false, primary: true},
token: {type: 'string', nullable: false, unique: true},
user_id: {type: 'integer', nullable: false, unsigned: true, references: 'users.id'},
client_id: {type: 'integer', nullable: false, unsigned: true, references: 'clients.id'},
expires: {type: 'bigInteger', nullable: false}
}
};
function isPost(jsonData) {
return jsonData.hasOwnProperty('html') && jsonData.hasOwnProperty('markdown') &&
jsonData.hasOwnProperty('title') && jsonData.hasOwnProperty('slug');
}
function isTag(jsonData) {
return jsonData.hasOwnProperty('name') && jsonData.hasOwnProperty('slug') &&
jsonData.hasOwnProperty('description') && jsonData.hasOwnProperty('parent');
}
function isUser(jsonData) {
return jsonData.hasOwnProperty('bio') && jsonData.hasOwnProperty('website') &&
jsonData.hasOwnProperty('status') && jsonData.hasOwnProperty('location');
}
function isNav(jsonData) {
return jsonData.hasOwnProperty('label') && jsonData.hasOwnProperty('url') &&
jsonData.hasOwnProperty('slug') && jsonData.hasOwnProperty('current');
}
module.exports.tables = db;
module.exports.checks = {
isPost: isPost,
isTag: isTag,
isUser: isUser,
isNav: isNav
};

View file

@ -0,0 +1,26 @@
function isPost(jsonData) {
return jsonData.hasOwnProperty('html') && jsonData.hasOwnProperty('markdown') &&
jsonData.hasOwnProperty('title') && jsonData.hasOwnProperty('slug');
}
function isTag(jsonData) {
return jsonData.hasOwnProperty('name') && jsonData.hasOwnProperty('slug') &&
jsonData.hasOwnProperty('description') && jsonData.hasOwnProperty('parent');
}
function isUser(jsonData) {
return jsonData.hasOwnProperty('bio') && jsonData.hasOwnProperty('website') &&
jsonData.hasOwnProperty('status') && jsonData.hasOwnProperty('location');
}
function isNav(jsonData) {
return jsonData.hasOwnProperty('label') && jsonData.hasOwnProperty('url') &&
jsonData.hasOwnProperty('slug') && jsonData.hasOwnProperty('current');
}
module.exports = {
isPost: isPost,
isTag: isTag,
isUser: isUser,
isNav: isNav
};

View file

@ -1,9 +1,9 @@
var _ = require('lodash'),
Promise = require('bluebird'),
config = require('../../config'),
schema = require('../schema').tables,
clients = require('./clients'),
i18n = require('../../i18n'),
schema = require('./schema'),
clients = require('./clients'),
dbConfig;

View file

@ -0,0 +1,11 @@
var schema = require('./schema'),
checks = require('./checks'),
commands = require('./commands'),
versioning = require('./versioning'),
defaultSettings = require('./default-settings');
module.exports.tables = schema;
module.exports.checks = checks;
module.exports.commands = commands;
module.exports.versioning = versioning;
module.exports.defaultSettings = defaultSettings;

View file

@ -0,0 +1,197 @@
module.exports = {
posts: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
title: {type: 'string', maxlength: 150, nullable: false},
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
markdown: {type: 'text', maxlength: 16777215, fieldtype: 'medium', nullable: true},
html: {type: 'text', maxlength: 16777215, fieldtype: 'medium', nullable: true},
image: {type: 'text', maxlength: 2000, nullable: true},
featured: {type: 'bool', nullable: false, defaultTo: false, validations: {isIn: [[0, 1, false, true]]}},
page: {type: 'bool', nullable: false, defaultTo: false, validations: {isIn: [[0, 1, false, true]]}},
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, validations: {isUUID: true}},
name: {type: 'string', maxlength: 150, nullable: false},
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
password: {type: 'string', maxlength: 60, nullable: false},
email: {type: 'string', maxlength: 254, nullable: false, unique: true, validations: {isEmail: 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, validations: {isEmptyOrURL: 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},
tour: {type: 'text', maxlength: 65535, 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, validations: {isUUID: true}},
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, validations: {isUUID: true}},
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}
},
permissions_apps: {
id: {type: 'increments', nullable: false, primary: true},
app_id: {type: 'integer', nullable: false},
permission_id: {type: 'integer', nullable: false}
},
settings: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
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', validations: {isIn: [['core', 'blog', 'theme', 'app', 'plugin', 'private']]}},
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, validations: {isUUID: true}},
name: {type: 'string', maxlength: 150, nullable: false, validations: {matches: /^([^,]|$)/}},
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
description: {type: 'string', maxlength: 200, nullable: true},
image: {type: 'text', maxlength: 2000, nullable: true},
hidden: {type: 'bool', nullable: false, defaultTo: false, validations: {isIn: [[0, 1, false, 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: 'posts.id'},
tag_id: {type: 'integer', nullable: false, unsigned: true, references: 'tags.id'},
sort_order: {type: 'integer', nullable: false, unsigned: true, defaultTo: 0}
},
apps: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
name: {type: 'string', maxlength: 150, nullable: false, unique: true},
slug: {type: 'string', maxlength: 150, nullable: false, unique: true},
version: {type: 'string', maxlength: 150, nullable: false},
status: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'inactive'},
created_at: {type: 'dateTime', nullable: false},
created_by: {type: 'integer', nullable: false},
updated_at: {type: 'dateTime', nullable: true},
updated_by: {type: 'integer', nullable: true}
},
app_settings: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
key: {type: 'string', maxlength: 150, nullable: false, unique: true},
value: {type: 'text', maxlength: 65535, nullable: true},
app_id: {type: 'integer', nullable: false, unsigned: true, references: 'apps.id'},
created_at: {type: 'dateTime', nullable: false},
created_by: {type: 'integer', nullable: false},
updated_at: {type: 'dateTime', nullable: true},
updated_by: {type: 'integer', nullable: true}
},
app_fields: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false, validations: {isUUID: true}},
key: {type: 'string', maxlength: 150, nullable: false},
value: {type: 'text', maxlength: 65535, nullable: true},
type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'html'},
app_id: {type: 'integer', nullable: false, unsigned: true, references: 'apps.id'},
relatable_id: {type: 'integer', nullable: false, unsigned: true},
relatable_type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'posts'},
active: {type: 'bool', nullable: false, defaultTo: true, validations: {isIn: [[0, 1, false, 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}
},
clients: {
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, unique: true},
secret: {type: 'string', maxlength: 150, nullable: false},
redirection_uri: {type: 'string', maxlength: 2000, nullable: true},
logo: {type: 'string', maxlength: 2000, nullable: true},
status: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'development'},
type: {type: 'string', maxlength: 150, nullable: false, defaultTo: 'ua'},
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}
},
client_trusted_domains: {
id: {type: 'increments', nullable: false, primary: true},
uuid: {type: 'string', maxlength: 36, nullable: false},
client_id: {type: 'integer', nullable: false, unsigned: true, references: 'clients.id'},
trusted_domain: {type: 'string', maxlength: 2000, nullable: true}
},
accesstokens: {
id: {type: 'increments', nullable: false, primary: true},
token: {type: 'string', nullable: false, unique: true},
user_id: {type: 'integer', nullable: false, unsigned: true, references: 'users.id'},
client_id: {type: 'integer', nullable: false, unsigned: true, references: 'clients.id'},
expires: {type: 'bigInteger', nullable: false}
},
refreshtokens: {
id: {type: 'increments', nullable: false, primary: true},
token: {type: 'string', nullable: false, unique: true},
user_id: {type: 'integer', nullable: false, unsigned: true, references: 'users.id'},
client_id: {type: 'integer', nullable: false, unsigned: true, references: 'clients.id'},
expires: {type: 'bigInteger', nullable: false}
}
};

View file

@ -2,8 +2,7 @@ var _ = require('lodash'),
errors = require('../../errors'),
config = require('../../config'),
i18n = require('../../i18n'),
defaultSettings = require('../default-settings'),
defaultSettings = require('./default-settings'),
initialVersion = '000',
defaultDatabaseVersion;

View file

@ -15,7 +15,7 @@ var Settings,
// It's much easier for us to work with it as a single level
// instead of iterating those categories every time
function parseDefaultSettings() {
var defaultSettingsInCategories = require('../data/default-settings.json'),
var defaultSettingsInCategories = require('../data/schema/').defaultSettings,
defaultSettingsFlattened = {};
_.each(defaultSettingsInCategories, function each(settings, categoryName) {

View file

@ -7,7 +7,7 @@ var testUtils = require('../utils/index'),
_ = require('lodash'),
// Stuff we are testing
versioning = require('../../server/data/versioning/index'),
versioning = require('../../server/data/schema').versioning,
exporter = require('../../server/data/export/index'),
sandbox = sinon.sandbox.create();

View file

@ -5,9 +5,9 @@ var should = require('should'),
crypto = require('crypto'),
// Stuff we are testing
defaultSettings = require('../../server/data/default-settings'),
schema = require('../../server/data/schema'),
permissions = require('../../server/data/fixtures/permissions/permissions');
permissions = require('../../server/data/migration/fixtures/permissions/permissions'),
defaultSettings = schema.defaultSettings;
// To stop jshint complaining
should.equal(true, true);

View file

@ -1,5 +1,4 @@
var Promise = require('bluebird'),
sequence = require('../../server/utils/sequence'),
_ = require('lodash'),
fs = require('fs-extra'),
path = require('path'),
@ -8,7 +7,8 @@ var Promise = require('bluebird'),
Models = require('../../server/models'),
SettingsAPI = require('../../server/api/settings'),
permissions = require('../../server/permissions'),
permsFixtures = require('../../server/data/fixtures/permissions/permissions.json'),
permsFixtures = require('../../server/data/migration/fixtures/permissions/permissions.json'),
sequence = require('../../server/utils/sequence'),
DataGenerator = require('./fixtures/data-generator'),
filterData = require('./fixtures/filter-param'),
API = require('./api'),