]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/application.js
ec1d7b1227c70bf1ce8f3254a2e59e16afc699d6
[github/Chocobozzz/PeerTube.git] / server / models / application.js
1 module.exports = function (sequelize, DataTypes) {
2 const Application = sequelize.define('Application',
3 {
4 sqlSchemaVersion: {
5 type: DataTypes.INTEGER,
6 defaultValue: 0
7 }
8 },
9 {
10 classMethods: {
11 loadSqlSchemaVersion,
12 updateSqlSchemaVersion
13 }
14 }
15 )
16
17 return Application
18 }
19
20 // ---------------------------------------------------------------------------
21
22 function loadSqlSchemaVersion (callback) {
23 const query = {
24 attributes: [ 'sqlSchemaVersion' ]
25 }
26
27 return this.findOne(query).asCallback(function (err, data) {
28 const version = data ? data.sqlSchemaVersion : 0
29
30 return callback(err, version)
31 })
32 }
33
34 function updateSqlSchemaVersion (newVersion, callback) {
35 return this.update({ sqlSchemaVersion: newVersion }).asCallback(callback)
36 }