Page MenuHomePhabricator

D9961.diff
No OneTemporary

D9961.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
@@ -5,6 +5,7 @@
import bots from 'lib/facts/bots.js';
import genesis from 'lib/facts/genesis.js';
import { policyTypes } from 'lib/facts/policies.js';
+import { specialRoles } from 'lib/permissions/special-roles.js';
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';
@@ -672,6 +673,25 @@
ADD COLUMN blob_holder char(36) CHARSET latin1
`),
],
+ [
+ 54,
+ async () => {
+ await dbQuery(
+ SQL`
+ ALTER TABLE roles
+ ADD COLUMN IF NOT EXISTS special_role
+ tinyint(2) UNSIGNED DEFAULT NULL,
+ DROP KEY IF EXISTS thread,
+ ADD KEY IF NOT EXISTS thread_special_role (thread, special_role);
+
+ UPDATE roles r
+ JOIN threads t ON r.id = t.default_role
+ SET r.special_role = ${specialRoles.DEFAULT_ROLE};
+ `,
+ { 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
@@ -135,7 +135,8 @@
thread bigint(20) NOT NULL,
name varchar(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL,
permissions json NOT NULL,
- creation_time bigint(20) NOT NULL
+ creation_time bigint(20) NOT NULL,
+ special_role tinyint(2) UNSIGNED DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE sessions (
@@ -341,7 +342,7 @@
ALTER TABLE roles
ADD PRIMARY KEY (id),
- ADD KEY thread (thread),
+ ADD KEY thread_special_role (thread, special_role),
ADD UNIQUE KEY thread_name (thread, name);
ALTER TABLE sessions
diff --git a/lib/permissions/special-roles.js b/lib/permissions/special-roles.js
new file mode 100644
--- /dev/null
+++ b/lib/permissions/special-roles.js
@@ -0,0 +1,5 @@
+// @flow
+
+export const specialRoles = Object.freeze({
+ DEFAULT_ROLE: 1,
+});

File Metadata

Mime Type
text/plain
Expires
Mon, Dec 2, 11:24 PM (21 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2609266
Default Alt Text
D9961.diff (2 KB)

Event Timeline