Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3323337
D9599.id32821.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
D9599.id32821.diff
View Options
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
@@ -8,6 +8,7 @@
import { messageTypes } from 'lib/types/message-types-enum.js';
import { threadPermissions } from 'lib/types/thread-permission-types.js';
import { threadTypes } from 'lib/types/thread-types-enum.js';
+import { permissionsToRemoveInMigration } from 'lib/utils/migration-utils.js';
import { dbQuery, SQL } from '../database/database.js';
import { processMessagesInDBForSearch } from '../database/search-utils.js';
@@ -634,6 +635,34 @@
moveToNonApacheConfig('facts/keyserver_url.json', '/keyserver/');
},
],
+ [
+ 51,
+ async () => {
+ if (permissionsToRemoveInMigration.length === 0) {
+ return;
+ }
+
+ const setClause = `permissions = JSON_REMOVE(permissions,
+ ${permissionsToRemoveInMigration.map(path => `'$.${path}'`).join(', ')}
+ )`;
+
+ const updateQuery = SQL`
+ UPDATE roles r
+ LEFT JOIN threads t ON t.id = r.thread
+ `;
+
+ updateQuery.append(SQL`SET `.append(setClause));
+
+ updateQuery.append(SQL`
+ WHERE r.name != 'Admins'
+ AND (t.type = ${threadTypes.COMMUNITY_ROOT}
+ OR t.type = ${threadTypes.COMMUNITY_ANNOUNCEMENT_ROOT})
+ `);
+
+ await dbQuery(updateQuery);
+ },
+ ],
+ [52, updateRolesAndPermissionsForAllThreads],
]);
const newDatabaseVersion: number = Math.max(...migrations.keys());
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 21, 3:38 AM (22 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2552476
Default Alt Text
D9599.id32821.diff (1 KB)
Attached To
Mode
D9599: [keyserver] Write MariaDB migration to remove incorrect permission from roles
Attached
Detach File
Event Timeline
Log In to Comment