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