Page MenuHomePhabricator

D11903.id39846.diff
No OneTemporary

D11903.id39846.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
@@ -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

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)

Event Timeline