1 import * as Sequelize from 'sequelize'
3 async function up (utils: {
4 transaction: Sequelize.Transaction,
5 queryInterface: Sequelize.QueryInterface,
6 sequelize: Sequelize.Sequelize,
10 // We'll add a unique index on filename, so delete duplicates or PeerTube won't start
11 const query = 'DELETE FROM "avatar" s1 ' +
12 'USING (SELECT MIN(id) as id, filename FROM "avatar" GROUP BY "filename" HAVING COUNT(*) > 1) s2 ' +
13 'WHERE s1."filename" = s2."filename" AND s1.id <> s2.id'
14 await utils.sequelize.query(query)
19 type: Sequelize.STRING,
24 await utils.queryInterface.addColumn('avatar', 'fileUrl', data)
29 type: Sequelize.BOOLEAN,
34 await utils.queryInterface.addColumn('avatar', 'onDisk', data)
38 const query = 'UPDATE "avatar" SET "onDisk" = true;'
39 await utils.sequelize.query(query)
44 type: Sequelize.BOOLEAN,
49 await utils.queryInterface.changeColumn('avatar', 'onDisk', data)
53 function down (options) {
54 throw new Error('Not implemented.')