Page MenuHomePhabricator

[keyserver] Migration to add Voiced role to announcement subchannels
AbandonedPublic

Authored by rohan on Nov 10 2023, 9:54 AM.
Tags
None
Referenced Files
F3628914: D9825.diff
Thu, Jan 2, 8:25 PM
Unknown Object (File)
Wed, Dec 11, 9:23 PM
Unknown Object (File)
Tue, Dec 10, 5:03 AM
Unknown Object (File)
Nov 24 2024, 10:06 PM
Unknown Object (File)
Nov 9 2024, 3:34 PM
Unknown Object (File)
Nov 9 2024, 1:46 PM
Unknown Object (File)
Nov 9 2024, 12:59 PM
Unknown Object (File)
Nov 9 2024, 8:29 AM
Subscribers

Details

Reviewers
atul
ginsu
ashoat
Summary

I think there's one announcement subchannel in production, so I need a migration to add the Voiced role to this channel. I've made it a general migration that should cover all announcement subchannels in case there have been new ones created since I began working on this task.

Depends on D9804

Test Plan

Ran the migration on announcement subchannels created on master (without Voiced), and then confirmed the roles were created by inspecting MariaDB. Also ran this query to check that the roles were created for the correct channels:

SELECT * FROM threads WHERE id IN (SELECT thread FROM roles WHERE name='Voiced')

I only got results back of threads that were announcement channels (both open and secret)

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

keyserver/src/database/migration-config.js
694–710

I thought it was safer to batch the role insertions, but not really sure if it's necessary at all so I can simplify this if needed to just

const newRows = [];
for (const threadID of threads) {
  const id = ids.shift();
  const time = Date.now();
  
   newRows.push([id, threadID, voicedRoleName, permissionsBlob, time]);
}

const query = SQL`
      INSERT INTO roles (id, thread, name, permissions, creation_time)
      VALUES ${newRows}
`;
await dbQuery(query);
ashoat requested changes to this revision.Nov 10 2023, 12:56 PM
ashoat added inline comments.
keyserver/src/database/migration-config.js
684

This is confusing to me. It looks like you're creating one new roles ID for each of the roles in rolePermissions, but I don't follow why you're doing this.

  1. Won't you need more ids if threads is longer?
  2. Why do you need IDs for the already-existing roles rows like Members?
694–710

I think it's probably good that you're batching them

This revision now requires changes to proceed.Nov 10 2023, 12:56 PM
keyserver/src/database/migration-config.js
684

Oh yeah this was a mistake on my part. It the number of ids should probably be the length of the threads array below since for each COMMUNITY_OPEN_ANNOUNCEMENT_SUBTHREAD and COMMUNITY_SECRET_ANNOUNCEMENT_SUBTHREAD, we'll need a new role

Update createIDs call to use threads.length. Tested this with more than rolePermissions.length (3) threads

This revision is now accepted and ready to land.Nov 11 2023, 10:59 AM
ashoat requested changes to this revision.Nov 11 2023, 3:22 PM
ashoat added inline comments.
keyserver/src/database/migration-config.js
672 ↗(On Diff #33089)

Is it a problem that you're using the permissions blob for COMMUNITY_OPEN_ANNOUNCEMENT_SUBTHREAD here, but the query below is also fetching COMMUNITY_SECRET_ANNOUNCEMENT_SUBTHREAD?

This revision now requires changes to proceed.Nov 11 2023, 3:22 PM
keyserver/src/database/migration-config.js
672 ↗(On Diff #33089)

No it won’t be an issue since they return the same permission blobs.

I thought since this was the case, there wasn’t much of a point calling getRolePermissionBlobs several times, and having it defined once was better

Okay that makes sense. And it doesn't matter if that changes in the past, since this migration won't be run in the future

This revision is now accepted and ready to land.Nov 11 2023, 4:07 PM

Abandoning this for now since we're reconsidering the Voiced approach