Socket
Socket
Sign inDemoInstall

ormius

Package Overview
Dependencies
13
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.4 to 0.0.5

23

cli/migrate.js

@@ -43,3 +43,7 @@ const arg = require('arg')

const migrateData = 'const { Migration } = require(\'ormius\')\n' +
'class NewMigration extends Migration {\n' +
'class NewMigration extends Migration {\n\n' +
' constructor() {\n' +
' super()\n' +
` this.modelName='${newModelName}'\n` +
' }\n\n' +
' changes() {\n' +

@@ -114,4 +118,19 @@ ` this.createTable(${JSON.stringify(options.filter(({ type }) => !RELATION_TYPES.includes(type)))})\n` +

console.log(results)
selectOption.close()
})
ormius.connection.query('SELECT migration FROM migrations', function (error, results) {
if (error) {
console.log('error', error)
throw error
}
const alreadyRanMigrations = results.map(({ migration }) => migration)
const migrationsToRun = dirs.filter(migration => !alreadyRanMigrations.includes(migration))
migrationsToRun.map(currentMigration => {
console.log(path.join(sourcePath, `${migrateFolder}/${currentMigration}/index.js`))
const module = require(`../${sourcePath}/migrations/${currentMigration}/index`)
const migrationModel = new module()
migrationModel.setConnection(ormius.connection)
migrationModel.setMigrationId(currentMigration)
migrationModel.changes()
})
})
}
class Migration {
#connection
modelName
migrationId

@@ -8,4 +10,21 @@ setConnection(connection) {

setMigrationId(migrationId) {
this.migrationId = migrationId
}
createTable(newTable) {
console.log(newTable)
const self = this
this.#connection.query(`CREATE TABLE ${this.modelName} (${newTable.map(({ type, name }) => `${name} ${type}`).join(',')})`, function (error) {
if (error) {
console.log('error', error)
throw error
}
self.#connection.query('INSERT INTO migrations (migration) VALUES (?)', [self.migrationId], function (error) {
if (error) {
console.log('error', error)
throw error
}
})
})
}

@@ -12,0 +31,0 @@ }

2

package.json
{
"name": "ormius",
"version": "0.0.4",
"version": "0.0.5",
"main": "index.js",

@@ -5,0 +5,0 @@ "author": "Adele Bendayan",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc