Skip to content
This repository was archived by the owner on Apr 3, 2019. It is now read-only.

Commit 1b59224

Browse files
deeptibaghelvbudhram
authored andcommitted
refactor(db): Fixes #340 Remove column createdAt on recoveryCode table (#342), r=@vbudhram
1 parent a841d06 commit 1b59224

File tree

4 files changed

+26
-2
lines changed

4 files changed

+26
-2
lines changed

lib/db/mysql.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ module.exports = function (log, error) {
14561456
}
14571457

14581458
const DELETE_RECOVERY_CODES = 'CALL deleteRecoveryCodes_1(?)'
1459-
const INSERT_RECOVERY_CODE = 'CALL createRecoveryCode_2(?, ?, ?)'
1459+
const INSERT_RECOVERY_CODE = 'CALL createRecoveryCode_3(?, ?, ?)'
14601460
MySql.prototype.replaceRecoveryCodes = function (uid, count) {
14611461

14621462
// Because of the hashing requirements the process of replacing

lib/db/patch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
// The expected patch level of the database. Update if you add a new
66
// patch in the ./schema/ directory.
7-
module.exports.level = 79
7+
module.exports.level = 80

lib/db/schema/patch-079-080.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
SET NAMES utf8mb4 COLLATE utf8mb4_bin;
2+
3+
-- createdAt value is never returned to the user and not used internally
4+
5+
ALTER TABLE recoveryCodes DROP COLUMN createdAt;
6+
7+
CREATE PROCEDURE `createRecoveryCode_3` (
8+
IN `uidArg` BINARY(16),
9+
IN `codeHashArg` BINARY(32),
10+
IN `saltArg` BINARY(32)
11+
)
12+
BEGIN
13+
14+
INSERT INTO recoveryCodes (uid, codeHash, salt) VALUES (uidArg, codeHashArg, saltArg);
15+
16+
END;
17+
18+
UPDATE dbMetadata SET value = '80' WHERE name = 'schema-patch-level';

lib/db/schema/patch-080-079.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- SET NAMES utf8mb4 COLLATE utf8mb4_bin;
2+
3+
-- DROP PROCEDURE `createRecoveryCode_3`;
4+
-- ALTER TABLE recoveryCodes ADD createdAt BIGINT UNSIGNED NOT NULL;
5+
6+
-- UPDATE dbMetadata SET value = '79' WHERE name = 'schema-patch-level';

0 commit comments

Comments
 (0)