Don't move the caption if it has the right name
[oweals/peertube.git] / server / models / application / application.ts
1 import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
2 import { AccountModel } from '../account/account'
3
4 @DefaultScope(() => ({
5   include: [
6     {
7       model: AccountModel,
8       required: true
9     }
10   ]
11 }))
12 @Table({
13   tableName: 'application',
14   timestamps: false
15 })
16 export class ApplicationModel extends Model<ApplicationModel> {
17
18   @AllowNull(false)
19   @Default(0)
20   @IsInt
21   @Column
22   migrationVersion: number
23
24   @HasOne(() => AccountModel, {
25     foreignKey: {
26       allowNull: true
27     },
28     onDelete: 'cascade'
29   })
30   Account: AccountModel
31
32   static countTotal () {
33     return ApplicationModel.count()
34   }
35
36   static load () {
37     return ApplicationModel.findOne()
38   }
39 }