Skip to content

Commit

Permalink
Replace mysql npm module with mysql2
Browse files Browse the repository at this point in the history
Our DB recently changed which auth mechanisms were allowed. We disabled
the native password option (the only one that the mysql npm module
supports). Thankfully, the mysql2 module is way more popular now and
supports the auth we want and the api is nearly identical.
  • Loading branch information
danielbeardsley committed Aug 30, 2024
1 parent e370ea6 commit 56a6d57
Show file tree
Hide file tree
Showing 4 changed files with 198 additions and 52 deletions.
2 changes: 1 addition & 1 deletion bin/migrate
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node

var config = require('../lib/config-loader');
var mysql = require('mysql'),
var mysql = require('mysql2'),
fs = require('fs');

var db = mysql.createConnection({
Expand Down
7 changes: 2 additions & 5 deletions lib/db.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var mysql = require("mysql"),
config = require("./config-loader"),
Promise = require("bluebird");
var mysql = require("mysql2/promise"),
config = require("./config-loader");

const pool = mysql.createPool({
host: config.mysql.host,
Expand All @@ -10,6 +9,4 @@ const pool = mysql.createPool({
charset: "utf8mb4",
});

pool.query = Promise.promisify(pool.query);

module.exports = pool;
Loading

0 comments on commit 56a6d57

Please sign in to comment.