Page MenuHomePhabricator

D6465.id21783.diff
No OneTemporary

D6465.id21783.diff

diff --git a/keyserver/src/database/migration-config.js b/keyserver/src/database/migration-config.js
--- a/keyserver/src/database/migration-config.js
+++ b/keyserver/src/database/migration-config.js
@@ -147,6 +147,25 @@
`);
},
],
+ [
+ 15,
+ async () => {
+ await dbQuery(
+ SQL`
+ ALTER TABLE uploads
+ ADD COLUMN IF NOT EXISTS thread bigint(20) DEFAULT NULL,
+ ADD INDEX IF NOT EXISTS thread (thread);
+
+ UPDATE uploads
+ SET thread = (
+ SELECT thread FROM messages
+ WHERE messages.id = uploads.container
+ );
+ `,
+ { multipleStatements: true },
+ );
+ },
+ ],
]);
const newDatabaseVersion: number = Math.max(...migrations.keys());
diff --git a/keyserver/src/database/setup-db.js b/keyserver/src/database/setup-db.js
--- a/keyserver/src/database/setup-db.js
+++ b/keyserver/src/database/setup-db.js
@@ -170,6 +170,7 @@
CREATE TABLE uploads (
id bigint(20) NOT NULL,
+ thread bigint(20) DEFAULT NULL,
uploader bigint(20) NOT NULL,
container bigint(20) DEFAULT NULL,
type varchar(255) NOT NULL,
@@ -320,7 +321,8 @@
ALTER TABLE uploads
ADD PRIMARY KEY (id),
- ADD INDEX container (container);
+ ADD INDEX container (container),
+ ADD INDEX thread (thread);
ALTER TABLE users
ADD PRIMARY KEY (id),

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 1:44 PM (14 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2560845
Default Alt Text
D6465.id21783.diff (1 KB)

Event Timeline