Fix PR feedback

This commit is contained in:
Jim Laurie 2018-01-11 15:00:34 +01:00
parent 054df448a9
commit f545f373aa
7 changed files with 60 additions and 66 deletions

View File

@ -235,10 +235,13 @@ module.exports = {
syncSchema: (cb) => { syncSchema: (cb) => {
const Model = strapi.plugins['users-permissions'].models.user; const Model = strapi.plugins['users-permissions'].models.user;
if (Model.orm === 'bookshelf') { if (Model.orm !== 'bookshelf') {
return cb();
}
const tableName = Model.collectionName; const tableName = Model.collectionName;
let queue = new Promise((resolve, reject) => { new Promise((resolve, reject) => {
strapi.connections[Model.connection].schema.hasTable(tableName) strapi.connections[Model.connection].schema.hasTable(tableName)
.then(exist => { .then(exist => {
if (!exist) { if (!exist) {
@ -266,9 +269,8 @@ CREATE TABLE "${tableName}" (
resolve(); resolve();
}); });
}); })
.then(() => {
queue = queue.then(() => {
const attributes = _.cloneDeep(Model.attributes); const attributes = _.cloneDeep(Model.attributes);
attributes.id = { attributes.id = {
type: 'integer' type: 'integer'
@ -296,12 +298,7 @@ CREATE TABLE "${tableName}" (
}); });
}; };
const testsColumns = []; const testsColumns = Object.entries(attributes).map(([attribute, description]) => columnExist(description, attribute));
_.forEach(attributes, (description, attribute) => {
testsColumns.push(columnExist(description, attribute));
});
Promise.all(testsColumns) Promise.all(testsColumns)
.then(() => { .then(() => {
if (!_.isEmpty(commands)) { if (!_.isEmpty(commands)) {
@ -320,8 +317,5 @@ ${commands}
cb(); cb();
}); });
}); });
} else {
cb();
}
} }
}; };