aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts10
-rw-r--r--server/initializers/migrations/0095-videos-privacy.ts35
2 files changed, 44 insertions, 1 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index adccb9f41..d349abaf0 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -12,10 +12,11 @@ import {
12 RemoteVideoRequestType, 12 RemoteVideoRequestType,
13 JobState 13 JobState
14} from '../../shared/models' 14} from '../../shared/models'
15import { VideoPrivacy } from '../../shared/models/videos/video-privacy.enum'
15 16
16// --------------------------------------------------------------------------- 17// ---------------------------------------------------------------------------
17 18
18const LAST_MIGRATION_VERSION = 90 19const LAST_MIGRATION_VERSION = 95
19 20
20// --------------------------------------------------------------------------- 21// ---------------------------------------------------------------------------
21 22
@@ -196,6 +197,12 @@ const VIDEO_LANGUAGES = {
196 14: 'Italian' 197 14: 'Italian'
197} 198}
198 199
200const VIDEO_PRIVACIES = {
201 [VideoPrivacy.PUBLIC]: 'Public',
202 [VideoPrivacy.UNLISTED]: 'Unlisted',
203 [VideoPrivacy.PRIVATE]: 'Private'
204}
205
199// --------------------------------------------------------------------------- 206// ---------------------------------------------------------------------------
200 207
201// Score a pod has when we create it as a friend 208// Score a pod has when we create it as a friend
@@ -394,6 +401,7 @@ export {
394 THUMBNAILS_SIZE, 401 THUMBNAILS_SIZE,
395 VIDEO_CATEGORIES, 402 VIDEO_CATEGORIES,
396 VIDEO_LANGUAGES, 403 VIDEO_LANGUAGES,
404 VIDEO_PRIVACIES,
397 VIDEO_LICENCES, 405 VIDEO_LICENCES,
398 VIDEO_RATE_TYPES 406 VIDEO_RATE_TYPES
399} 407}
diff --git a/server/initializers/migrations/0095-videos-privacy.ts b/server/initializers/migrations/0095-videos-privacy.ts
new file mode 100644
index 000000000..4c2bf91d0
--- /dev/null
+++ b/server/initializers/migrations/0095-videos-privacy.ts
@@ -0,0 +1,35 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction,
5 queryInterface: Sequelize.QueryInterface,
6 sequelize: Sequelize.Sequelize,
7 db: any
8}): Promise<void> {
9 const q = utils.queryInterface
10
11 const data = {
12 type: Sequelize.INTEGER,
13 defaultValue: null,
14 allowNull: true
15 }
16 await q.addColumn('Videos', 'privacy', data)
17
18 const query = 'UPDATE "Videos" SET "privacy" = 1'
19 const options = {
20 type: Sequelize.QueryTypes.BULKUPDATE
21 }
22 await utils.sequelize.query(query, options)
23
24 data.allowNull = false
25 await q.changeColumn('Videos', 'privacy', data)
26}
27
28function down (options) {
29 throw new Error('Not implemented.')
30}
31
32export {
33 up,
34 down
35}