aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/models/application/application.ts
blob: 854a5fb368550b4744fa194637c9f1631f1ab2a8 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                                                                                                            
 







                                










                                                               







                               


                                   



                                     
 
import { AllowNull, Column, Default, DefaultScope, HasOne, IsInt, Model, Table } from 'sequelize-typescript'
import { AccountModel } from '../account/account'

@DefaultScope({
  include: [
    {
      model: () => AccountModel,
      required: true
    }
  ]
})
@Table({
  tableName: 'application'
})
export class ApplicationModel extends Model<ApplicationModel> {

  @AllowNull(false)
  @Default(0)
  @IsInt
  @Column
  migrationVersion: number

  @HasOne(() => AccountModel, {
    foreignKey: {
      allowNull: true
    },
    onDelete: 'cascade'
  })
  Account: AccountModel

  static countTotal () {
    return ApplicationModel.count()
  }

  static load () {
    return ApplicationModel.findOne()
  }
}