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