diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 6aaef3aa2..1623e6f42 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -24,7 +24,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 605 +const LAST_MIGRATION_VERSION = 610 // --------------------------------------------------------------------------- diff --git a/server/initializers/migrations/0610-views-index.ts b/server/initializers/migrations/0610-views-index.ts new file mode 100644 index 000000000..02ee21172 --- /dev/null +++ b/server/initializers/migrations/0610-views-index.ts @@ -0,0 +1,20 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface + sequelize: Sequelize.Sequelize + db: any +}): Promise { + + await utils.sequelize.query('DROP INDEX IF EXISTS video_views;') +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} diff --git a/server/models/video/video.ts b/server/models/video/video.ts index b4c7da655..b3543ddf2 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -426,7 +426,12 @@ export type AvailableForListIDsOptions = { ] }, { fields: [ 'duration' ] }, - { fields: [ 'views' ] }, + { + fields: [ + { name: 'views', order: 'DESC' }, + { name: 'id', order: 'ASC' } + ] + }, { fields: [ 'channelId' ] }, { fields: [ 'originallyPublishedAt' ],