aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-file.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-file.ts')
-rw-r--r--server/models/video/video-file.ts25
1 files changed, 24 insertions, 1 deletions
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 3bc4855f3..0907ea569 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -1,5 +1,18 @@
1import { values } from 'lodash' 1import { values } from 'lodash'
2import { AllowNull, BelongsTo, Column, CreatedAt, DataType, Default, ForeignKey, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' 2import {
3 AllowNull,
4 BelongsTo,
5 Column,
6 CreatedAt,
7 DataType,
8 Default,
9 ForeignKey,
10 HasMany,
11 Is,
12 Model,
13 Table,
14 UpdatedAt
15} from 'sequelize-typescript'
3import { 16import {
4 isVideoFileInfoHashValid, 17 isVideoFileInfoHashValid,
5 isVideoFileResolutionValid, 18 isVideoFileResolutionValid,
@@ -10,6 +23,7 @@ import { CONSTRAINTS_FIELDS } from '../../initializers'
10import { throwIfNotValid } from '../utils' 23import { throwIfNotValid } from '../utils'
11import { VideoModel } from './video' 24import { VideoModel } from './video'
12import * as Sequelize from 'sequelize' 25import * as Sequelize from 'sequelize'
26import { VideoRedundancyModel } from '../redundancy/video-redundancy'
13 27
14@Table({ 28@Table({
15 tableName: 'videoFile', 29 tableName: 'videoFile',
@@ -70,6 +84,15 @@ export class VideoFileModel extends Model<VideoFileModel> {
70 }) 84 })
71 Video: VideoModel 85 Video: VideoModel
72 86
87 @HasMany(() => VideoRedundancyModel, {
88 foreignKey: {
89 allowNull: false
90 },
91 onDelete: 'CASCADE',
92 hooks: true
93 })
94 RedundancyVideos: VideoRedundancyModel[]
95
73 static isInfohashExists (infoHash: string) { 96 static isInfohashExists (infoHash: string) {
74 const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1' 97 const query = 'SELECT 1 FROM "videoFile" WHERE "infoHash" = $infoHash LIMIT 1'
75 const options = { 98 const options = {