X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Finitializers%2Fmigrations%2F0080-video-channels.ts;h=ef3e15968ca012373762d2f24c1f9bc105dede6f;hb=8d07888728bc5aabc7d0cd6211bc49fc45fd0353;hp=fc55ef3a214d681554a467318a467e0e1819951a;hpb=faab3a8453e2af92f95518e55e00293ac140b6e8;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/initializers/migrations/0080-video-channels.ts b/server/initializers/migrations/0080-video-channels.ts index fc55ef3a2..ef3e15968 100644 --- a/server/initializers/migrations/0080-video-channels.ts +++ b/server/initializers/migrations/0080-video-channels.ts @@ -1,10 +1,10 @@ +import { buildUUID } from '@shared/extra-utils' import * as Sequelize from 'sequelize' -import * as uuidv4 from 'uuid/v4' async function up (utils: { - transaction: Sequelize.Transaction, - queryInterface: Sequelize.QueryInterface, - sequelize: Sequelize.Sequelize, + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface + sequelize: Sequelize.Sequelize db: any }): Promise { const q = utils.queryInterface @@ -23,7 +23,7 @@ async function up (utils: { { const authors = await utils.db.Author.findAll() for (const author of authors) { - author.uuid = uuidv4() + author.uuid = buildUUID() await author.save() } } @@ -34,7 +34,7 @@ async function up (utils: { // Create one author per user that does not already exist const users = await utils.db.User.findAll() for (const user of users) { - const author = await utils.db.Author.find({ where: { userId: user.id }}) + const author = await utils.db.Author.find({ where: { userId: user.id } }) if (!author) { await utils.db.Author.create({ name: user.username, @@ -69,12 +69,12 @@ async function up (utils: { const options = { type: Sequelize.QueryTypes.SELECT } - const rawVideos = await utils.sequelize.query(query, options) + const rawVideos = await utils.sequelize.query(query, options) as any for (const rawVideo of rawVideos) { - const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId }}) + const videoChannel = await utils.db.VideoChannel.findOne({ where: { authorId: rawVideo.authorId } }) - const video = await utils.db.Video.findById(rawVideo.id) + const video = await utils.db.Video.findByPk(rawVideo.id) video.channelId = videoChannel.id await video.save() }