Skip to content

Commit

Permalink
fix: generate uuid in js migration instead of from db
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Kolstad committed Feb 19, 2021
1 parent 153fd97 commit ba57822
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
"response-time": "^2.3.2",
"serve-favicon": "^2.5.0",
"unleash-frontend": "3.11.4",
"uuid": "^8.3.2",
"yargs": "^16.0.3"
},
"devDependencies": {
Expand Down
5 changes: 4 additions & 1 deletion src/migrations/20210218090213-generate-server-identifier.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
'use strict';

const { v4 } = require('uuid');

exports.up = function(db, cb) {
const instanceId = v4();
db.runSql(
`
INSERT INTO settings(name, content) VALUES ('instanceInfo', json_build_object('id', gen_random_uuid()));
INSERT INTO settings(name, content) VALUES ('instanceInfo', json_build_object('id', '${instanceId}'));
`,
cb,
);
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6330,6 +6330,11 @@ uuid@^3.2.1, uuid@^3.3.2, uuid@^3.3.3:
resolved "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==

uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==

v8-compile-cache@^2.0.3:
version "2.1.1"
resolved "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.1.1.tgz"
Expand Down

0 comments on commit ba57822

Please sign in to comment.