diff options
author | Chocobozzz <me@florianbigard.com> | 2017-12-15 18:44:17 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2017-12-19 10:53:16 +0100 |
commit | 555846c99fa43b237814d32bd55d8124405187d3 (patch) | |
tree | 6693c6384b4a26b3ee30028c4102f39356cb925e /server/initializers/migrations | |
parent | 39fdb3c032875ab8c9a1e5e52f76d3baa0ac4e63 (diff) | |
download | PeerTube-555846c99fa43b237814d32bd55d8124405187d3.tar.gz PeerTube-555846c99fa43b237814d32bd55d8124405187d3.tar.zst PeerTube-555846c99fa43b237814d32bd55d8124405187d3.zip |
Add public/private keys generation in migrations
Diffstat (limited to 'server/initializers/migrations')
-rw-r--r-- | server/initializers/migrations/0130-video-channel-actor.ts | 13 |
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 @@ | |||
1 | import * as Sequelize from 'sequelize' | 1 | import * as Sequelize from 'sequelize' |
2 | import { DataType } from 'sequelize-typescript' | 2 | import { DataType } from 'sequelize-typescript' |
3 | import { createPrivateAndPublicKeys } from '../../helpers' | ||
3 | 4 | ||
4 | async function up (utils: { | 5 | async 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 | ||
228 | function down (options) { | 241 | function down (options) { |