mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +02:00
Add migration (for db, folders...) mechanism
This commit is contained in:
parent
44c5275e1b
commit
00d6b0dda4
8 changed files with 174 additions and 21 deletions
31
server/models/application.js
Normal file
31
server/models/application.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
const mongoose = require('mongoose')
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const ApplicationSchema = mongoose.Schema({
|
||||
mongoSchemaVersion: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
})
|
||||
|
||||
ApplicationSchema.statics = {
|
||||
loadMongoSchemaVersion: loadMongoSchemaVersion,
|
||||
updateMongoSchemaVersion: updateMongoSchemaVersion
|
||||
}
|
||||
|
||||
mongoose.model('Application', ApplicationSchema)
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function loadMongoSchemaVersion (callback) {
|
||||
return this.findOne({}, { mongoSchemaVersion: 1 }, function (err, data) {
|
||||
const version = data ? data.mongoSchemaVersion : 0
|
||||
|
||||
return callback(err, version)
|
||||
})
|
||||
}
|
||||
|
||||
function updateMongoSchemaVersion (newVersion, callback) {
|
||||
return this.update({}, { mongoSchemaVersion: newVersion }, callback)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue