Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

feathers-knex-modeler

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

feathers-knex-modeler - npm Package Compare versions

Comparing version 1.0.7 to 1.0.8

2

package.json
{
"name": "feathers-knex-modeler",
"version": "1.0.7",
"version": "1.0.8",
"description": "This package allows you to easily extend a table while you are developing it without requiring you to drop tables.",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -93,12 +93,12 @@ /* eslint-disable no-console */

const self = this
await pWaitFor(async () => self.hasColumn(tableName, columnName))
return pWaitFor(async () => self.hasColumn(tableName, columnName))
}
alterColumn (column, option) {
return new Promise((resolve, reject) => {
const self = this
const db = self.db
let errored = false
self.debug(`Modifying column: ${column.name}`)
self.debug(option)
db.schema.alterTable(self.name, (table) => {
async alterColumn (column, option) {
const self = this
const db = self.db
let errored = false
self.debug(`Modifying column: ${column.name}`)
self.debug(option)
try {
await db.schema.alterTable(self.name, (table) => {
let alterCommand

@@ -115,3 +115,2 @@ let typeOfColumn = option.type

}
switch (typeOfColumn) {

@@ -146,19 +145,16 @@ case 'notNullable': {

}
return alterCommand.alter()
alterCommand.alter()
})
.catch((err) => {
let alreadyExists = (err.message.indexOf('already exists') !== -1)
if (alreadyExists === false) {
errored = err
}
return err
})
.then(() => {
if (errored === false) {
return resolve()
} else {
return reject(errored)
}
})
})
} catch (err) {
let alreadyExists = (err.message.indexOf('already exists') !== -1)
if (alreadyExists === false) {
errored = err
}
}
if (errored === false) {
return true
} else {
throw errored
}
}

@@ -184,21 +180,20 @@ async createColumn (column) {

}
alterTable (hasColumn, column) {
return new Promise((resolve, reject) => {
const self = this
const db = self.db
db.schema.alterTable(self.name, (table) => {
let alterations = []
if (hasColumn === false) {
table[column.type](column.name)
return resolve(self.alterTable(true, column))
} else {
for (let optionIndex = 0; optionIndex < column.options.length; optionIndex++) {
alterations.push(self.alterColumn(column, column.options[optionIndex]))
}
return Promise.all(alterations)
async alterTable (hasColumn, column) {
const self = this
const db = self.db
let alterations = []
await db.schema.alterTable(self.name, (table) => {
if (hasColumn === false) {
table[column.type](column.name)
} else {
for (let optionIndex = 0; optionIndex < column.options.length; optionIndex++) {
alterations.push(self.alterColumn(column, column.options[optionIndex]))
}
})
.then(() => resolve())
.catch((err) => reject(err))
}
})
if (hasColumn === false) {
return self.alterTable(true, column)
} else {
return Promise.all(alterations)
}
}

@@ -261,7 +256,8 @@ async createColumns () {

const self = this
let dependedOnTables = []
for (let dependsIndex = 0; dependsIndex < self.depends.length; dependsIndex++) {
let dependedOnTableName = self.depends[dependsIndex]
await self.hasTable(dependedOnTableName)
dependedOnTables.push(self.hasTable(dependedOnTableName))
}
return true
return Promise.all(dependedOnTables)
}

@@ -268,0 +264,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc