aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/application.js26
-rw-r--r--server/models/video.js7
2 files changed, 24 insertions, 9 deletions
diff --git a/server/models/application.js b/server/models/application.js
index ec1d7b122..4114ed76d 100644
--- a/server/models/application.js
+++ b/server/models/application.js
@@ -1,15 +1,15 @@
1module.exports = function (sequelize, DataTypes) { 1module.exports = function (sequelize, DataTypes) {
2 const Application = sequelize.define('Application', 2 const Application = sequelize.define('Application',
3 { 3 {
4 sqlSchemaVersion: { 4 migrationVersion: {
5 type: DataTypes.INTEGER, 5 type: DataTypes.INTEGER,
6 defaultValue: 0 6 defaultValue: 0
7 } 7 }
8 }, 8 },
9 { 9 {
10 classMethods: { 10 classMethods: {
11 loadSqlSchemaVersion, 11 loadMigrationVersion,
12 updateSqlSchemaVersion 12 updateMigrationVersion
13 } 13 }
14 } 14 }
15 ) 15 )
@@ -19,18 +19,28 @@ module.exports = function (sequelize, DataTypes) {
19 19
20// --------------------------------------------------------------------------- 20// ---------------------------------------------------------------------------
21 21
22function loadSqlSchemaVersion (callback) { 22function loadMigrationVersion (callback) {
23 const query = { 23 const query = {
24 attributes: [ 'sqlSchemaVersion' ] 24 attributes: [ 'migrationVersion' ]
25 } 25 }
26 26
27 return this.findOne(query).asCallback(function (err, data) { 27 return this.findOne(query).asCallback(function (err, data) {
28 const version = data ? data.sqlSchemaVersion : 0 28 const version = data ? data.migrationVersion : 0
29 29
30 return callback(err, version) 30 return callback(err, version)
31 }) 31 })
32} 32}
33 33
34function updateSqlSchemaVersion (newVersion, callback) { 34function updateMigrationVersion (newVersion, transaction, callback) {
35 return this.update({ sqlSchemaVersion: newVersion }).asCallback(callback) 35 const options = {
36 where: {}
37 }
38
39 if (!callback) {
40 transaction = callback
41 } else {
42 options.transaction = transaction
43 }
44
45 return this.update({ migrationVersion: newVersion }, options).asCallback(callback)
36} 46}
diff --git a/server/models/video.js b/server/models/video.js
index 0023a24e1..af05a861f 100644
--- a/server/models/video.js
+++ b/server/models/video.js
@@ -16,7 +16,7 @@ const modelUtils = require('./utils')
16// --------------------------------------------------------------------------- 16// ---------------------------------------------------------------------------
17 17
18module.exports = function (sequelize, DataTypes) { 18module.exports = function (sequelize, DataTypes) {
19// TODO: add indexes on searchable columns 19 // TODO: add indexes on searchable columns
20 const Video = sequelize.define('Video', 20 const Video = sequelize.define('Video',
21 { 21 {
22 id: { 22 id: {
@@ -50,6 +50,7 @@ module.exports = function (sequelize, DataTypes) {
50 50
51 generateThumbnailFromBase64, 51 generateThumbnailFromBase64,
52 getDurationFromFile, 52 getDurationFromFile,
53 list,
53 listForApi, 54 listForApi,
54 listByHostAndRemoteId, 55 listByHostAndRemoteId,
55 listOwnedAndPopulateAuthorAndTags, 56 listOwnedAndPopulateAuthorAndTags,
@@ -310,6 +311,10 @@ function getDurationFromFile (videoPath, callback) {
310 }) 311 })
311} 312}
312 313
314function list (callback) {
315 return this.find().asCallback()
316}
317
313function listForApi (start, count, sort, callback) { 318function listForApi (start, count, sort, callback) {
314 const query = { 319 const query = {
315 offset: start, 320 offset: start,