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 @@ -780,6 +780,26 @@ ); }, ], + [ + 63, + async () => { + await dbQuery( + SQL` + ALTER TABLE uploads + ADD COLUMN user_container varchar(255) + CHARSET latin1 + COLLATE latin1_bin + DEFAULT NULL + AFTER container, + ADD INDEX user_container (user_container); + UPDATE IGNORE uploads u + INNER JOIN users us ON us.id = u.container + SET u.container = NULL, u.user_container = us.id; + `, + { 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 @@ -197,6 +197,8 @@ thread bigint(20) DEFAULT NULL, uploader varchar(255) CHARSET latin1 COLLATE latin1_bin NOT NULL, container bigint(20) DEFAULT NULL, + user_container varchar(255) + CHARSET latin1 COLLATE latin1_bin DEFAULT NULL, type varchar(255) CHARSET latin1 COLLATE latin1_swedish_ci NOT NULL, filename varchar(255) NOT NULL, mime varchar(255) CHARSET latin1 COLLATE latin1_swedish_ci NOT NULL, @@ -374,6 +376,7 @@ ALTER TABLE uploads ADD PRIMARY KEY (id), ADD INDEX container (container), + ADD INDEX user_container (user_container), ADD INDEX thread (thread); ALTER TABLE users