Fix PR feedback

This commit is contained in:
Jim LAURIE 2019-01-31 14:17:52 +01:00
parent fdcecff2e6
commit 6cbddab6c8
2 changed files with 6 additions and 4 deletions

View File

@ -482,7 +482,6 @@ module.exports = function(strapi) {
try {
const connection = strapi.config.connections[definition.connection];
let columns = Object.keys(attributes).filter(attribute => ['string', 'text'].includes(attributes[attribute].type));
let indexes;
if (!columns.length) {
// No text columns founds, exit from creating Fulltext Index
@ -498,12 +497,12 @@ module.exports = function(strapi) {
// Create fulltext indexes for every column.
await ORM.knex.raw(`CREATE FULLTEXT INDEX SEARCH_${_.toUpper(_.snakeCase(table))} ON \`${table}\` (${columns})`);
break;
case 'pg':
case 'pg': {
// Enable extension to allow GIN indexes.
await ORM.knex.raw('CREATE EXTENSION IF NOT EXISTS pg_trgm');
// Create GIN indexes for every column.
indexes = columns
const indexes = columns
.map(column => {
const indexName = `${_.snakeCase(table)}_${column}`;
const attribute = _.toLower(column) === column
@ -515,6 +514,7 @@ module.exports = function(strapi) {
await Promise.all(indexes);
break;
}
}
} catch (e) {
// Handle duplicate errors.

View File

@ -150,7 +150,9 @@ module.exports = strapi => {
break;
case 'sqlite3':
// Create the directory if it does not exist.
if (!fs.existsSync(fileDirectory)){
try {
fs.statSync(fileDirectory);
} catch (err) {
fs.mkdirSync(fileDirectory);
}