--- /dev/null
+import * as Sequelize from 'sequelize'
+
+async function up (utils: {
+ transaction: Sequelize.Transaction,
+ queryInterface: Sequelize.QueryInterface,
+ sequelize: Sequelize.Sequelize,
+ db: any
+}): Promise<void> {
+ const indexNames = [
+ 'video_category',
+ 'video_licence',
+ 'video_nsfw',
+ 'video_language',
+ 'video_wait_transcoding',
+ 'video_state',
+ 'video_remote',
+ 'video_likes'
+ ]
+
+ for (const indexName of indexNames) {
+ await utils.sequelize.query('DROP INDEX IF EXISTS "' + indexName + '";')
+ }
+}
+
+function down (options) {
+ throw new Error('Not implemented.')
+}
+
+export {
+ up,
+ down
+}
{ fields: [ 'createdAt' ] },
{ fields: [ 'publishedAt' ] },
{ fields: [ 'duration' ] },
- { fields: [ 'category' ] },
- { fields: [ 'licence' ] },
- { fields: [ 'nsfw' ] },
- { fields: [ 'language' ] },
- { fields: [ 'waitTranscoding' ] },
- { fields: [ 'state' ] },
- { fields: [ 'remote' ] },
{ fields: [ 'views' ] },
- { fields: [ 'likes' ] },
{ fields: [ 'channelId' ] },
+ {
+ fields: [ 'category' ], // We don't care videos with an unknown category
+ where: {
+ category: {
+ [Sequelize.Op.ne]: null
+ }
+ }
+ },
+ {
+ fields: [ 'licence' ], // We don't care videos with an unknown licence
+ where: {
+ licence: {
+ [Sequelize.Op.ne]: null
+ }
+ }
+ },
+ {
+ fields: [ 'language' ], // We don't care videos with an unknown language
+ where: {
+ language: {
+ [Sequelize.Op.ne]: null
+ }
+ }
+ },
+ {
+ fields: [ 'nsfw' ], // Most of the videos are not NSFW
+ where: {
+ nsfw: true
+ }
+ },
+ {
+ fields: [ 'remote' ], // Only index local videos
+ where: {
+ remote: false
+ }
+ },
{
fields: [ 'uuid' ],
unique: true