Socket
Socket
Sign inDemoInstall

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.2 to 1.0.3

2

package.json
{
"name": "feathers-knex-modeler",
"version": "1.0.2",
"version": "1.0.3",
"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",

@@ -90,19 +90,43 @@ /* eslint-disable no-console */

let errored = false
self.debug(`Modifying column: ${column.name}`)
self.debug(option)
db.schema.alterTable(self.name, (table) => {
try {
let typeOfColumn = option.type
let argument = option.argument
if (_.isFunction(table[column.type](column.name)[typeOfColumn]) === true) {
table[column.type](column.name)[typeOfColumn](argument).alter()
} else {
self.debug(`${typeOfColumn} is not a function. Error occured on table: ${self.name}`)
let alterCommand
let typeOfColumn = option.type
let argument = option.argument
let columnToAlter = table[column.type](column.name)
switch (typeOfColumn) {
case 'notNullable': {
alterCommand = columnToAlter.notNullable()
break
}
} catch (err) {
self.debug(`Failed to alter column on table: ${self.name}`)
self.debug(err)
case 'nullable': {
alterCommand = columnToAlter.nullable()
break
}
case 'primary': {
alterCommand = columnToAlter.primary()
break
}
case 'references': {
alterCommand = columnToAlter.references(argument)
break
}
case 'unique': {
alterCommand = columnToAlter.unique()
break
}
default: {
if (_.isFunction(table[column.type](column.name)[typeOfColumn]) === true) {
alterCommand = columnToAlter[typeOfColumn](argument)
} else {
self.debug(`Unable to find the function to perform the alter on the column: ${column.name}`)
}
}
}
return table
return alterCommand.alter()
})
.catch((err) => {
let alreadyExists = err.message.indexOf('already exists') !== -1
let alreadyExists = (err.message.indexOf('already exists') !== -1)
if (alreadyExists === false) {

@@ -109,0 +133,0 @@ errored = err

@@ -10,12 +10,12 @@ /* eslint-disable no-undef */

before(function (done) {
db.schema.hasTable(fixtures.testOne.name)
db.schema.hasTable(fixtures.testTwo.name)
.then((hasTable) => {
if (hasTable === true) {
return db.raw(`drop table ${fixtures.testOne.name}`)
return db.raw(`drop table ${fixtures.testTwo.name}`)
}
})
.then(() => db.schema.hasTable(fixtures.testTwo.name))
.then(() => db.schema.hasTable(fixtures.testOne.name))
.then((hasTable) => {
if (hasTable === true) {
return db.raw(`drop table ${fixtures.testTwo.name}`)
return db.raw(`drop table ${fixtures.testOne.name}`)
}

@@ -22,0 +22,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