import * as Sequelize from 'sequelize'
-import * as uuidv4 from 'uuid/v4'
+import { v4 as uuidv4 } from 'uuid'
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<void> {
const q = utils.queryInterface
// 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,
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()
}