diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-05-15 22:22:03 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-05-20 09:57:40 +0200 |
commit | 65fcc3119c334b75dd13bcfdebf186afdc580a8f (patch) | |
tree | 4f2158c61a9b7c3f47cfa233d01413b946ee53c0 /server/models/application.js | |
parent | d5f345ed4cfac4e1fa84dcb4fce1cda4d32f9c73 (diff) | |
download | PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.gz PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.tar.zst PeerTube-65fcc3119c334b75dd13bcfdebf186afdc580a8f.zip |
First typescript iteration
Diffstat (limited to 'server/models/application.js')
-rw-r--r-- | server/models/application.js | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/server/models/application.js b/server/models/application.js deleted file mode 100644 index 64e1a0540..000000000 --- a/server/models/application.js +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | 'use strict' | ||
2 | |||
3 | module.exports = function (sequelize, DataTypes) { | ||
4 | const Application = sequelize.define('Application', | ||
5 | { | ||
6 | migrationVersion: { | ||
7 | type: DataTypes.INTEGER, | ||
8 | defaultValue: 0, | ||
9 | allowNull: false, | ||
10 | validate: { | ||
11 | isInt: true | ||
12 | } | ||
13 | } | ||
14 | }, | ||
15 | { | ||
16 | classMethods: { | ||
17 | loadMigrationVersion, | ||
18 | updateMigrationVersion | ||
19 | } | ||
20 | } | ||
21 | ) | ||
22 | |||
23 | return Application | ||
24 | } | ||
25 | |||
26 | // --------------------------------------------------------------------------- | ||
27 | |||
28 | function loadMigrationVersion (callback) { | ||
29 | const query = { | ||
30 | attributes: [ 'migrationVersion' ] | ||
31 | } | ||
32 | |||
33 | return this.findOne(query).asCallback(function (err, data) { | ||
34 | const version = data ? data.migrationVersion : null | ||
35 | |||
36 | return callback(err, version) | ||
37 | }) | ||
38 | } | ||
39 | |||
40 | function updateMigrationVersion (newVersion, transaction, callback) { | ||
41 | const options = { | ||
42 | where: {} | ||
43 | } | ||
44 | |||
45 | if (!callback) { | ||
46 | transaction = callback | ||
47 | } else { | ||
48 | options.transaction = transaction | ||
49 | } | ||
50 | |||
51 | return this.update({ migrationVersion: newVersion }, options).asCallback(callback) | ||
52 | } | ||