]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/application.js
Update scripts with postgresql
[github/Chocobozzz/PeerTube.git] / server / models / application.js
CommitLineData
feb4bdfd
C
1module.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}
00d6b0dd
C
19
20// ---------------------------------------------------------------------------
21
feb4bdfd
C
22function loadSqlSchemaVersion (callback) {
23 const query = {
24 attributes: [ 'sqlSchemaVersion' ]
00d6b0dd 25 }
00d6b0dd 26
feb4bdfd
C
27 return this.findOne(query).asCallback(function (err, data) {
28 const version = data ? data.sqlSchemaVersion : 0
00d6b0dd
C
29
30 return callback(err, version)
31 })
32}
33
feb4bdfd
C
34function updateSqlSchemaVersion (newVersion, callback) {
35 return this.update({ sqlSchemaVersion: newVersion }).asCallback(callback)
00d6b0dd 36}