aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0130-video-channel-actor.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2017-12-15 18:44:17 +0100
committerChocobozzz <me@florianbigard.com>2017-12-19 10:53:16 +0100
commit555846c99fa43b237814d32bd55d8124405187d3 (patch)
tree6693c6384b4a26b3ee30028c4102f39356cb925e /server/initializers/migrations/0130-video-channel-actor.ts
parent39fdb3c032875ab8c9a1e5e52f76d3baa0ac4e63 (diff)
downloadPeerTube-555846c99fa43b237814d32bd55d8124405187d3.tar.gz
PeerTube-555846c99fa43b237814d32bd55d8124405187d3.tar.zst
PeerTube-555846c99fa43b237814d32bd55d8124405187d3.zip
Add public/private keys generation in migrations
Diffstat (limited to 'server/initializers/migrations/0130-video-channel-actor.ts')
-rw-r--r--server/initializers/migrations/0130-video-channel-actor.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/server/initializers/migrations/0130-video-channel-actor.ts b/server/initializers/migrations/0130-video-channel-actor.ts
index 0b665b0c7..15b67be81 100644
--- a/server/initializers/migrations/0130-video-channel-actor.ts
+++ b/server/initializers/migrations/0130-video-channel-actor.ts
@@ -1,5 +1,6 @@
1import * as Sequelize from 'sequelize' 1import * as Sequelize from 'sequelize'
2import { DataType } from 'sequelize-typescript' 2import { DataType } from 'sequelize-typescript'
3import { createPrivateAndPublicKeys } from '../../helpers'
3 4
4async function up (utils: { 5async function up (utils: {
5 transaction: Sequelize.Transaction, 6 transaction: Sequelize.Transaction,
@@ -223,6 +224,18 @@ async function up (utils: {
223 await utils.queryInterface.removeColumn('videoChannel', columnToDelete) 224 await utils.queryInterface.removeColumn('videoChannel', columnToDelete)
224 } 225 }
225 } 226 }
227
228 {
229 const query = 'SELECT * FROM "actor" WHERE "serverId" IS NULL AND "publicKey" IS NULL'
230 const [ res ] = await utils.sequelize.query(query)
231
232 for (const actor of res) {
233 const { privateKey, publicKey } = await createPrivateAndPublicKeys()
234
235 const queryUpdate = `UPDATE "actor" SET "publicKey" = '${publicKey}', "privateKey" = '${privateKey}' WHERE id = ${actor.id}`
236 await utils.sequelize.query(queryUpdate)
237 }
238 }
226} 239}
227 240
228function down (options) { 241function down (options) {