Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduce duplicated code for data migrations #433

Merged
merged 3 commits into from
Sep 9, 2021

Conversation

russdj
Copy link
Contributor

@russdj russdj commented Sep 3, 2021

resolves #432

connection = await pool.getConnection()
for (const statement of this._upCommands) {
console.log(`[DB] Execute: ${statement}`)
connection.query(statement)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing await

await connection.query(statement)

connection = await pool.getConnection()
for (const statement of this._downCommands) {
console.log(`[DB] Execute: ${statement}`)
connection.query(statement)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing await

await connection.query(statement)

finally {
await connection.release()
}
migrationHandler.up(pool, __filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need await

await migrationHandler.up(pool, __filename)

finally {
await connection.release()
}
migrationHandler.down(pool, __filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need await

await migrationHandler.up(pool, __filename)

finally {
await connection.release()
}
migrationHandler.up(pool, __filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need await

await migrationHandler.up(pool, __filename)

finally {
await connection.release()
}
migrationHandler.down(pool, __filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need await

await migrationHandler.up(pool, __filename)

finally {
await connection.release()
}
migrationHandler.up(pool, __filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need await

await migrationHandler.up(pool, __filename)

finally {
await connection.release()
}
migrationHandler.down(pool, __filename)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need await

await migrationHandler.up(pool, __filename)

@@ -1,4 +1,4 @@
const path = require('path')
const MigrationHandler = require('../migrationHandler')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect case:

require('../MigrationHandler')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When class file is relocated, please adjust require:

const MigrationHandler = require('./lib/MigrationHandler')

@@ -1,4 +1,4 @@
const path = require('path')
const MigrationHandler = require('../migrationHandler')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incorrect case:

require('../MigrationHandler')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When class file is relocated, please adjust require:

const MigrationHandler = require('./lib/MigrationHandler')

@@ -0,0 +1,51 @@
"use strict";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please place this file at api/source/service/mysql/migrations/lib/MigrationHandler.js

@@ -1,4 +1,4 @@
const path = require('path')
const MigrationHandler = require('../MigrationHandler')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When class file is relocated, please adjust require:

const MigrationHandler = require('./lib/MigrationHandler')

@csmig csmig merged commit cc63b2e into NUWCDIVNPT:main Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redesign/refactor MySQL migration code
2 participants