Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3500286
D4151.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4151.diff
View Options
diff --git a/keyserver/src/database/migrations.js b/keyserver/src/database/migrations.js
--- a/keyserver/src/database/migrations.js
+++ b/keyserver/src/database/migrations.js
@@ -6,6 +6,7 @@
import { getMessageForException } from 'lib/utils/errors';
import { dbQuery, SQL } from './database';
+import { setupDB } from './setup-db';
async function makeSureBaseRoutePathExists(filePath: string): Promise<void> {
let readFile, json;
@@ -90,7 +91,7 @@
async function migrate(): Promise<boolean> {
let dbVersion = null;
try {
- dbVersion = await getDBVersion();
+ dbVersion = await setUpDBAndReturnVersion();
console.log(`(node:${process.pid}) DB version: ${dbVersion}`);
} catch (e) {
const dbVersionExceptionMessage = String(getMessageForException(e));
@@ -120,7 +121,19 @@
return true;
}
-async function getDBVersion(): Promise<number> {
+async function setUpDBAndReturnVersion(): Promise<number> {
+ try {
+ return await fetchDBVersion();
+ } catch (e) {
+ if (e.errno !== 1146) {
+ throw e;
+ }
+ await setupDB();
+ return await fetchDBVersion();
+ }
+}
+
+async function fetchDBVersion(): Promise<number> {
const versionQuery = SQL`
SELECT data
FROM metadata
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Dec 21, 1:11 AM (18 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2684404
Default Alt Text
D4151.diff (1 KB)
Attached To
Mode
D4151: [keyserver] Call setupDB from DB migration if meta table is missing
Attached
Detach File
Event Timeline
Log In to Comment