]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/application/application.ts
Fix createdAt/updatedAt issues
[github/Chocobozzz/PeerTube.git] / server / models / application / application.ts
CommitLineData
50d6de9c
C
1import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
2import { AccountModel } from '../account/account'
3fd3ab2d 3
3acc5084 4@DefaultScope(() => ({
50d6de9c
C
5 include: [
6 {
3acc5084 7 model: AccountModel,
50d6de9c
C
8 required: true
9 }
10 ]
3acc5084 11}))
3fd3ab2d 12@Table({
4f0f2ab2
C
13 tableName: 'application',
14 timestamps: false
3fd3ab2d
C
15})
16export class ApplicationModel extends Model<ApplicationModel> {
17
18 @AllowNull(false)
19 @Default(0)
20 @IsInt
21 @Column
22 migrationVersion: number
23
50d6de9c
C
24 @HasOne(() => AccountModel, {
25 foreignKey: {
26 allowNull: true
27 },
28 onDelete: 'cascade'
29 })
30 Account: AccountModel
31
3fd3ab2d
C
32 static countTotal () {
33 return ApplicationModel.count()
34 }
50d6de9c
C
35
36 static load () {
37 return ApplicationModel.findOne()
38 }
00d6b0dd 39}