aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/migrations/0530-user-feed-token.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-25 11:04:18 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-25 11:07:56 +0100
commit18490b07650d77d7fe376970b749af5a8c672fd6 (patch)
tree89741e63e34c2659487c9afa8309755064cb0c39 /server/initializers/migrations/0530-user-feed-token.ts
parent5beb89f223539f1e415a976ff104f772526b4d20 (diff)
downloadPeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.tar.gz
PeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.tar.zst
PeerTube-18490b07650d77d7fe376970b749af5a8c672fd6.zip
Fix migration and test
Diffstat (limited to 'server/initializers/migrations/0530-user-feed-token.ts')
-rw-r--r--server/initializers/migrations/0530-user-feed-token.ts40
1 files changed, 0 insertions, 40 deletions
diff --git a/server/initializers/migrations/0530-user-feed-token.ts b/server/initializers/migrations/0530-user-feed-token.ts
deleted file mode 100644
index 421016b11..000000000
--- a/server/initializers/migrations/0530-user-feed-token.ts
+++ /dev/null
@@ -1,40 +0,0 @@
1import * as Sequelize from 'sequelize'
2import { v4 as uuidv4 } from 'uuid'
3
4async function up (utils: {
5 transaction: Sequelize.Transaction
6 queryInterface: Sequelize.QueryInterface
7 sequelize: Sequelize.Sequelize
8 db: any
9}): Promise<void> {
10 const q = utils.queryInterface
11
12 // Create uuid column for users
13 const userFeedTokenUUID = {
14 type: Sequelize.UUID,
15 defaultValue: Sequelize.UUIDV4,
16 allowNull: true
17 }
18 await q.addColumn('user', 'feedToken', userFeedTokenUUID)
19
20 // Set UUID to previous users
21 {
22 const query = 'SELECT * FROM "user" WHERE "feedToken" IS NULL'
23 const options = { type: Sequelize.QueryTypes.SELECT as Sequelize.QueryTypes.SELECT }
24 const users = await utils.sequelize.query<any>(query, options)
25
26 for (const user of users) {
27 const queryUpdate = `UPDATE "user" SET "feedToken" = '${uuidv4()}' WHERE id = ${user.id}`
28 await utils.sequelize.query(queryUpdate)
29 }
30 }
31}
32
33function down (options) {
34 throw new Error('Not implemented.')
35}
36
37export {
38 up,
39 down
40}