Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3305033
D11903.id39846.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11903.id39846.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
@@ -769,6 +769,47 @@
);
},
],
+ [
+ 62,
+ async () => {
+ const selectCommunitesQuery = SQL`
+ SELECT t.id
+ FROM threads t
+ WHERE t.depth = 0
+ `;
+ const createTableQuery = SQL`
+ CREATE TABLE IF NOT EXISTS communities (
+ id bigint(20) NOT NULL,
+ farcaster_channel_id varchar(255) CHARSET latin1 DEFAULT NULL,
+ blob_holder char(36) CHARSET latin1 DEFAULT NULL
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
+
+ ALTER TABLE communities
+ ADD PRIMARY KEY (id);
+ `;
+
+ const [selectCommunitesQueryResult] = await Promise.all([
+ dbQuery(selectCommunitesQuery),
+ dbQuery(createTableQuery, { multipleStatements: true }),
+ ]);
+
+ const communityIDs = selectCommunitesQueryResult[0].map(({ id }) =>
+ id.toString(),
+ );
+
+ const newRows = [];
+ for (const id of communityIDs) {
+ newRows.push([id]);
+ }
+
+ const insertCommunitiesQuery = SQL`
+ INSERT INTO communities (id)
+ VALUES ${newRows}
+ `;
+
+ await dbQuery(insertCommunitiesQuery);
+ },
+ ],
]);
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
@@ -296,6 +296,12 @@
COLLATE latin1_bin NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
+ CREATE TABLE communities (
+ id bigint(20) NOT NULL,
+ farcaster_channel_id varchar(255) CHARSET latin1 DEFAULT NULL,
+ blob_holder char(36) CHARSET latin1 DEFAULT NULL
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
+
ALTER TABLE cookies
ADD PRIMARY KEY (id),
ADD UNIQUE KEY device_token (device_token(512)),
@@ -423,6 +429,9 @@
ALTER TABLE olm_accounts
ADD PRIMARY KEY (is_content);
+
+ ALTER TABLE communities
+ ADD PRIMARY KEY (id);
`,
{ multipleStatements: true },
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 19, 12:21 PM (22 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2539229
Default Alt Text
D11903.id39846.diff (2 KB)
Attached To
Mode
D11903: [keyserver] introduce a table for communities
Attached
Detach File
Event Timeline
Log In to Comment