aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/application.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/application.ts')
-rw-r--r--server/models/application.ts57
1 files changed, 0 insertions, 57 deletions
diff --git a/server/models/application.ts b/server/models/application.ts
deleted file mode 100644
index 55bb40d84..000000000
--- a/server/models/application.ts
+++ /dev/null
@@ -1,57 +0,0 @@
1import * as Sequelize from 'sequelize'
2
3import { addMethodsToModel } from './utils'
4import {
5 ApplicationClass,
6 ApplicationAttributes,
7 ApplicationInstance,
8
9 ApplicationMethods
10} from './application-interface'
11
12let Application: Sequelize.Model<ApplicationInstance, ApplicationAttributes>
13let loadMigrationVersion: ApplicationMethods.LoadMigrationVersion
14let updateMigrationVersion: ApplicationMethods.UpdateMigrationVersion
15
16export default function defineApplication (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.DataTypes) {
17 Application = sequelize.define<ApplicationInstance, ApplicationAttributes>('Application',
18 {
19 migrationVersion: {
20 type: DataTypes.INTEGER,
21 defaultValue: 0,
22 allowNull: false,
23 validate: {
24 isInt: true
25 }
26 }
27 }
28 )
29
30 const classMethods = [ loadMigrationVersion, updateMigrationVersion ]
31 addMethodsToModel(Application, classMethods)
32
33 return Application
34}
35
36// ---------------------------------------------------------------------------
37
38loadMigrationVersion = function (callback: ApplicationMethods.LoadMigrationVersionCallback) {
39 const query = {
40 attributes: [ 'migrationVersion' ]
41 }
42
43 return Application.findOne(query).asCallback(function (err, data) {
44 const version = data ? data.migrationVersion : null
45
46 return callback(err, version)
47 })
48}
49
50updateMigrationVersion = function (newVersion: number, transaction: Sequelize.Transaction, callback: ApplicationMethods.UpdateMigrationVersionCallback) {
51 const options: Sequelize.UpdateOptions = {
52 where: {},
53 transaction: transaction
54 }
55
56 return Application.update({ migrationVersion: newVersion }, options).asCallback(callback)
57}