]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/initializers/migrations/0175-actor-follow-counts.ts
allow private syndication feeds via a user feedToken
[github/Chocobozzz/PeerTube.git] / server / initializers / migrations / 0175-actor-follow-counts.ts
CommitLineData
32b2b43c 1import * as Sequelize from 'sequelize'
32b2b43c
C
2
3async function up (utils: {
a1587156
C
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
32b2b43c
C
6 sequelize: Sequelize.Sequelize
7}): Promise<void> {
8 const query = 'UPDATE "actor" SET ' +
9 '"followersCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."targetActorId"), ' +
10 '"followingCount" = (SELECT COUNT(*) FROM "actorFollow" WHERE "actor"."id" = "actorFollow"."actorId") ' +
11 'WHERE "actor"."serverId" IS NULL'
12
13 await utils.sequelize.query(query)
14}
15
16function down (options) {
17 throw new Error('Not implemented.')
18}
19
20export {
21 up,
22 down
23}