X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fmigrations%2F0135-video-channel-actor.ts;h=3f620dfa3b462c376573241df6f953dace1d4c76;hb=1ebddadd0704812a4600c39cabe2268321e88331;hp=9b5acb338631493f6f085b0f0e5fa9cfd31c07ec;hpb=f9fcb010b03fed60f07b5e09d4dfc8ba2a720741;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/migrations/0135-video-channel-actor.ts b/server/initializers/migrations/0135-video-channel-actor.ts index 9b5acb338..3f620dfa3 100644 --- a/server/initializers/migrations/0135-video-channel-actor.ts +++ b/server/initializers/migrations/0135-video-channel-actor.ts @@ -1,10 +1,10 @@ import * as Sequelize from 'sequelize' import { DataType } from 'sequelize-typescript' -import { createPrivateAndPublicKeys } from '../../helpers' +import { createPrivateAndPublicKeys } from '../../helpers/peertube-crypto' async function up (utils: { - transaction: Sequelize.Transaction, - queryInterface: Sequelize.QueryInterface, + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface sequelize: Sequelize.Sequelize }): Promise { // Create actor table @@ -64,10 +64,10 @@ async function up (utils: { type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" ) - SELECT + SELECT 'Application', uuid, name, url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", - "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" - FROM account + "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" + FROM account WHERE "applicationId" IS NOT NULL ` await utils.sequelize.query(query1) @@ -79,10 +79,10 @@ async function up (utils: { type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" ) - SELECT + SELECT 'Person', uuid, name, url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", - "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" - FROM account + "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" + FROM account WHERE "applicationId" IS NULL ` await utils.sequelize.query(query2) @@ -108,17 +108,17 @@ async function up (utils: { } { - const query = ` - INSERT INTO actor + const query = ` + INSERT INTO actor ( - type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", + type, uuid, "preferredUsername", url, "publicKey", "privateKey", "followersCount", "followingCount", "inboxUrl", "outboxUrl", "sharedInboxUrl", "followersUrl", "followingUrl", "avatarId", "serverId", "createdAt", "updatedAt" ) - SELECT - 'Group', "videoChannel".uuid, "videoChannel".uuid, "videoChannel".url, null, null, 0, 0, "videoChannel".url || '/inbox', + SELECT + 'Group', "videoChannel".uuid, "videoChannel".uuid, "videoChannel".url, null, null, 0, 0, "videoChannel".url || '/inbox', "videoChannel".url || '/outbox', "videoChannel".url || '/inbox', "videoChannel".url || '/followers', "videoChannel".url || '/following', - null, account."serverId", "videoChannel"."createdAt", "videoChannel"."updatedAt" - FROM "videoChannel" + null, account."serverId", "videoChannel"."createdAt", "videoChannel"."updatedAt" + FROM "videoChannel" INNER JOIN "account" on "videoChannel"."accountId" = "account".id ` await utils.sequelize.query(query) @@ -157,13 +157,13 @@ async function up (utils: { } { - const query1 = `UPDATE "actorFollow" - SET "actorId" = + const query1 = `UPDATE "actorFollow" + SET "actorId" = (SELECT "account"."actorId" FROM account WHERE "account"."id" = "actorFollow"."actorId")` await utils.sequelize.query(query1) - const query2 = `UPDATE "actorFollow" - SET "targetActorId" = + const query2 = `UPDATE "actorFollow" + SET "targetActorId" = (SELECT "account"."actorId" FROM account WHERE "account"."id" = "actorFollow"."targetActorId")` await utils.sequelize.query(query2) @@ -189,8 +189,8 @@ async function up (utils: { await utils.queryInterface.removeConstraint('videoShare', 'videoShare_accountId_fkey') } - const query = `UPDATE "videoShare" - SET "actorId" = + const query = `UPDATE "videoShare" + SET "actorId" = (SELECT "actorId" FROM account WHERE id = "videoShare"."actorId")` await utils.sequelize.query(query) @@ -239,7 +239,8 @@ async function up (utils: { { const query = 'SELECT * FROM "actor" WHERE "serverId" IS NULL AND "publicKey" IS NULL' - const [ res ] = await utils.sequelize.query(query) + const options = { type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT } + const [ res ] = await utils.sequelize.query(query, options) for (const actor of res) { const { privateKey, publicKey } = await createPrivateAndPublicKeys()