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<void> {
// Create actor table
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)
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)
}
{
- 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)
}
{
- 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)
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)
{
const query = 'SELECT * FROM "actor" WHERE "serverId" IS NULL AND "publicKey" IS NULL'
const options = { type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT }
- const [ res ] = await utils.sequelize.query(query, options)
+ const [ res ] = await utils.sequelize.query<any>(query, options)
for (const actor of res) {
const { privateKey, publicKey } = await createPrivateAndPublicKeys()