aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/checker-after-init.ts27
-rw-r--r--server/initializers/checker-before-init.ts7
-rw-r--r--server/initializers/config.ts30
-rw-r--r--server/initializers/constants.ts35
-rw-r--r--server/initializers/database.ts10
-rw-r--r--server/initializers/migrations/0610-views-index copy.ts (renamed from server/initializers/migrations/0610-views-index.ts)0
-rw-r--r--server/initializers/migrations/0615-latest-versions-notification-settings.ts44
-rw-r--r--server/initializers/migrations/0620-latest-versions-application.ts27
-rw-r--r--server/initializers/migrations/0625-latest-versions-notification.ts26
-rw-r--r--server/initializers/migrations/0630-banner.ts50
-rw-r--r--server/initializers/migrations/0635-actor-image-size.ts35
11 files changed, 255 insertions, 36 deletions
diff --git a/server/initializers/checker-after-init.ts b/server/initializers/checker-after-init.ts
index 2b00e2047..a93c8b7fd 100644
--- a/server/initializers/checker-after-init.ts
+++ b/server/initializers/checker-after-init.ts
@@ -1,16 +1,17 @@
1import * as config from 'config' 1import * as config from 'config'
2import { isProdInstance, isTestInstance } from '../helpers/core-utils' 2import { uniq } from 'lodash'
3import { UserModel } from '../models/account/user'
4import { getServerActor, ApplicationModel } from '../models/application/application'
5import { OAuthClientModel } from '../models/oauth/oauth-client'
6import { URL } from 'url' 3import { URL } from 'url'
7import { CONFIG, isEmailEnabled } from './config' 4import { getFFmpegVersion } from '@server/helpers/ffmpeg-utils'
8import { logger } from '../helpers/logger' 5import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
9import { RecentlyAddedStrategy } from '../../shared/models/redundancy' 6import { RecentlyAddedStrategy } from '../../shared/models/redundancy'
7import { isProdInstance, isTestInstance, parseSemVersion } from '../helpers/core-utils'
10import { isArray } from '../helpers/custom-validators/misc' 8import { isArray } from '../helpers/custom-validators/misc'
11import { uniq } from 'lodash' 9import { logger } from '../helpers/logger'
10import { UserModel } from '../models/account/user'
11import { ApplicationModel, getServerActor } from '../models/application/application'
12import { OAuthClientModel } from '../models/oauth/oauth-client'
13import { CONFIG, isEmailEnabled } from './config'
12import { WEBSERVER } from './constants' 14import { WEBSERVER } from './constants'
13import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
14 15
15async function checkActivityPubUrls () { 16async function checkActivityPubUrls () {
16 const actor = await getServerActor() 17 const actor = await getServerActor()
@@ -176,11 +177,21 @@ async function applicationExist () {
176 return totalApplication !== 0 177 return totalApplication !== 0
177} 178}
178 179
180async function checkFFmpegVersion () {
181 const version = await getFFmpegVersion()
182 const { major, minor } = parseSemVersion(version)
183
184 if (major < 4 || (major === 4 && minor < 1)) {
185 logger.warn('Your ffmpeg version (%s) is outdated. PeerTube supports ffmpeg >= 4.1. Please upgrade.', version)
186 }
187}
188
179// --------------------------------------------------------------------------- 189// ---------------------------------------------------------------------------
180 190
181export { 191export {
182 checkConfig, 192 checkConfig,
183 clientsExist, 193 clientsExist,
194 checkFFmpegVersion,
184 usersExist, 195 usersExist,
185 applicationExist, 196 applicationExist,
186 checkActivityPubUrls 197 checkActivityPubUrls
diff --git a/server/initializers/checker-before-init.ts b/server/initializers/checker-before-init.ts
index 565e0d1fa..2864b0287 100644
--- a/server/initializers/checker-before-init.ts
+++ b/server/initializers/checker-before-init.ts
@@ -1,5 +1,5 @@
1import * as config from 'config' 1import * as config from 'config'
2import { promisify0 } from '../helpers/core-utils' 2import { parseSemVersion, promisify0 } from '../helpers/core-utils'
3import { logger } from '../helpers/logger' 3import { logger } from '../helpers/logger'
4 4
5// ONLY USE CORE MODULES IN THIS FILE! 5// ONLY USE CORE MODULES IN THIS FILE!
@@ -17,6 +17,7 @@ function checkMissedConfig () {
17 'log.level', 17 'log.level',
18 'user.video_quota', 'user.video_quota_daily', 18 'user.video_quota', 'user.video_quota_daily',
19 'csp.enabled', 'csp.report_only', 'csp.report_uri', 19 'csp.enabled', 'csp.report_only', 'csp.report_uri',
20 'security.frameguard.enabled',
20 'cache.previews.size', 'cache.captions.size', 'cache.torrents.size', 'admin.email', 'contact_form.enabled', 21 'cache.previews.size', 'cache.captions.size', 'cache.torrents.size', 'admin.email', 'contact_form.enabled',
21 'signup.enabled', 'signup.limit', 'signup.requires_email_verification', 22 'signup.enabled', 'signup.limit', 'signup.requires_email_verification',
22 'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist', 23 'signup.filters.cidr.whitelist', 'signup.filters.cidr.blacklist',
@@ -37,6 +38,7 @@ function checkMissedConfig () {
37 'theme.default', 38 'theme.default',
38 'remote_redundancy.videos.accept_from', 39 'remote_redundancy.videos.accept_from',
39 'federation.videos.federate_unlisted', 'federation.videos.cleanup_remote_interactions', 40 'federation.videos.federate_unlisted', 'federation.videos.cleanup_remote_interactions',
41 'peertube.check_latest_version.enabled', 'peertube.check_latest_version.url',
40 'search.remote_uri.users', 'search.remote_uri.anonymous', 'search.search_index.enabled', 'search.search_index.url', 42 'search.remote_uri.users', 'search.remote_uri.anonymous', 'search.search_index.enabled', 'search.search_index.url',
41 'search.search_index.disable_local_search', 'search.search_index.is_default_search', 43 'search.search_index.disable_local_search', 'search.search_index.is_default_search',
42 'live.enabled', 'live.allow_replay', 'live.max_duration', 'live.max_user_lives', 'live.max_instance_lives', 44 'live.enabled', 'live.allow_replay', 'live.max_duration', 'live.max_user_lives', 'live.max_instance_lives',
@@ -102,8 +104,7 @@ async function checkFFmpeg (CONFIG: { TRANSCODING: { ENABLED: boolean } }) {
102 104
103function checkNodeVersion () { 105function checkNodeVersion () {
104 const v = process.version 106 const v = process.version
105 const majorString = v.split('.')[0].replace('v', '') 107 const { major } = parseSemVersion(v)
106 const major = parseInt(majorString, 10)
107 108
108 logger.debug('Checking NodeJS version %s.', v) 109 logger.debug('Checking NodeJS version %s.', v)
109 110
diff --git a/server/initializers/config.ts b/server/initializers/config.ts
index c16b63c33..5281d3a66 100644
--- a/server/initializers/config.ts
+++ b/server/initializers/config.ts
@@ -1,12 +1,13 @@
1import * as bytes from 'bytes'
1import { IConfig } from 'config' 2import { IConfig } from 'config'
3import decache from 'decache'
2import { dirname, join } from 'path' 4import { dirname, join } from 'path'
5import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
6import { BroadcastMessageLevel } from '@shared/models/server'
3import { VideosRedundancyStrategy } from '../../shared/models' 7import { VideosRedundancyStrategy } from '../../shared/models'
8import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
4// Do not use barrels, remain constants as independent as possible 9// Do not use barrels, remain constants as independent as possible
5import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils' 10import { buildPath, parseBytes, parseDurationToMs, root } from '../helpers/core-utils'
6import { NSFWPolicyType } from '../../shared/models/videos/nsfw-policy.type'
7import * as bytes from 'bytes'
8import { VideoRedundancyConfigFilter } from '@shared/models/redundancy/video-redundancy-config-filter.type'
9import { BroadcastMessageLevel } from '@shared/models/server'
10 11
11// Use a variable to reload the configuration if we need 12// Use a variable to reload the configuration if we need
12let config: IConfig = require('config') 13let config: IConfig = require('config')
@@ -59,7 +60,7 @@ const CONFIG = {
59 }, 60 },
60 STORAGE: { 61 STORAGE: {
61 TMP_DIR: buildPath(config.get<string>('storage.tmp')), 62 TMP_DIR: buildPath(config.get<string>('storage.tmp')),
62 AVATARS_DIR: buildPath(config.get<string>('storage.avatars')), 63 ACTOR_IMAGES: buildPath(config.get<string>('storage.avatars')),
63 LOG_DIR: buildPath(config.get<string>('storage.logs')), 64 LOG_DIR: buildPath(config.get<string>('storage.logs')),
64 VIDEOS_DIR: buildPath(config.get<string>('storage.videos')), 65 VIDEOS_DIR: buildPath(config.get<string>('storage.videos')),
65 STREAMING_PLAYLISTS_DIR: buildPath(config.get<string>('storage.streaming_playlists')), 66 STREAMING_PLAYLISTS_DIR: buildPath(config.get<string>('storage.streaming_playlists')),
@@ -133,6 +134,11 @@ const CONFIG = {
133 REPORT_ONLY: config.get<boolean>('csp.report_only'), 134 REPORT_ONLY: config.get<boolean>('csp.report_only'),
134 REPORT_URI: config.get<string>('csp.report_uri') 135 REPORT_URI: config.get<string>('csp.report_uri')
135 }, 136 },
137 SECURITY: {
138 FRAMEGUARD: {
139 ENABLED: config.get<boolean>('security.frameguard.enabled')
140 }
141 },
136 TRACKER: { 142 TRACKER: {
137 ENABLED: config.get<boolean>('tracker.enabled'), 143 ENABLED: config.get<boolean>('tracker.enabled'),
138 PRIVATE: config.get<boolean>('tracker.private'), 144 PRIVATE: config.get<boolean>('tracker.private'),
@@ -163,6 +169,12 @@ const CONFIG = {
163 CLEANUP_REMOTE_INTERACTIONS: config.get<boolean>('federation.videos.cleanup_remote_interactions') 169 CLEANUP_REMOTE_INTERACTIONS: config.get<boolean>('federation.videos.cleanup_remote_interactions')
164 } 170 }
165 }, 171 },
172 PEERTUBE: {
173 CHECK_LATEST_VERSION: {
174 ENABLED: config.get<boolean>('peertube.check_latest_version.enabled'),
175 URL: config.get<string>('peertube.check_latest_version.url')
176 }
177 },
166 ADMIN: { 178 ADMIN: {
167 get EMAIL () { return config.get<string>('admin.email') } 179 get EMAIL () { return config.get<string>('admin.email') }
168 }, 180 },
@@ -404,7 +416,7 @@ function buildVideosRedundancy (objs: any[]): VideosRedundancyStrategy[] {
404 416
405export function reloadConfig () { 417export function reloadConfig () {
406 418
407 function directory () { 419 function getConfigDirectory () {
408 if (process.env.NODE_CONFIG_DIR) { 420 if (process.env.NODE_CONFIG_DIR) {
409 return process.env.NODE_CONFIG_DIR 421 return process.env.NODE_CONFIG_DIR
410 } 422 }
@@ -413,15 +425,17 @@ export function reloadConfig () {
413 } 425 }
414 426
415 function purge () { 427 function purge () {
428 const directory = getConfigDirectory()
429
416 for (const fileName in require.cache) { 430 for (const fileName in require.cache) {
417 if (fileName.includes(directory()) === false) { 431 if (fileName.includes(directory) === false) {
418 continue 432 continue
419 } 433 }
420 434
421 delete require.cache[fileName] 435 delete require.cache[fileName]
422 } 436 }
423 437
424 delete require.cache[require.resolve('config')] 438 decache('config')
425 } 439 }
426 440
427 purge() 441 purge()
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 50467f408..1802257df 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -24,12 +24,12 @@ import { CONFIG, registerConfigChangedHandler } from './config'
24 24
25// --------------------------------------------------------------------------- 25// ---------------------------------------------------------------------------
26 26
27const LAST_MIGRATION_VERSION = 612 27const LAST_MIGRATION_VERSION = 635
28 28
29// --------------------------------------------------------------------------- 29// ---------------------------------------------------------------------------
30 30
31const API_VERSION = 'v1' 31const API_VERSION = 'v1'
32const PEERTUBE_VERSION = require(join(root(), 'package.json')).version 32const PEERTUBE_VERSION: string = require(join(root(), 'package.json')).version
33 33
34const PAGINATION = { 34const PAGINATION = {
35 GLOBAL: { 35 GLOBAL: {
@@ -207,6 +207,7 @@ const SCHEDULER_INTERVALS_MS = {
207 updateVideos: 60000, // 1 minute 207 updateVideos: 60000, // 1 minute
208 youtubeDLUpdate: 60000 * 60 * 24, // 1 day 208 youtubeDLUpdate: 60000 * 60 * 24, // 1 day
209 checkPlugins: CONFIG.PLUGINS.INDEX.CHECK_LATEST_VERSIONS_INTERVAL, 209 checkPlugins: CONFIG.PLUGINS.INDEX.CHECK_LATEST_VERSIONS_INTERVAL,
210 checkPeerTubeVersion: 60000 * 60 * 24, // 1 day
210 autoFollowIndexInstances: 60000 * 60 * 24, // 1 day 211 autoFollowIndexInstances: 60000 * 60 * 24, // 1 day
211 removeOldViews: 60000 * 60 * 24, // 1 day 212 removeOldViews: 60000 * 60 * 24, // 1 day
212 removeOldHistory: 60000 * 60 * 24, // 1 day 213 removeOldHistory: 60000 * 60 * 24, // 1 day
@@ -304,7 +305,7 @@ const CONSTRAINTS_FIELDS = {
304 PUBLIC_KEY: { min: 10, max: 5000 }, // Length 305 PUBLIC_KEY: { min: 10, max: 5000 }, // Length
305 PRIVATE_KEY: { min: 10, max: 5000 }, // Length 306 PRIVATE_KEY: { min: 10, max: 5000 }, // Length
306 URL: { min: 3, max: 2000 }, // Length 307 URL: { min: 3, max: 2000 }, // Length
307 AVATAR: { 308 IMAGE: {
308 EXTNAME: [ '.png', '.jpeg', '.jpg', '.gif', '.webp' ], 309 EXTNAME: [ '.png', '.jpeg', '.jpg', '.gif', '.webp' ],
309 FILE_SIZE: { 310 FILE_SIZE: {
310 max: 2 * 1024 * 1024 // 2MB 311 max: 2 * 1024 * 1024 // 2MB
@@ -465,6 +466,8 @@ const MIMETYPES = {
465 IMAGE: { 466 IMAGE: {
466 MIMETYPE_EXT: { 467 MIMETYPE_EXT: {
467 'image/png': '.png', 468 'image/png': '.png',
469 'image/gif': '.gif',
470 'image/webp': '.webp',
468 'image/jpg': '.jpg', 471 'image/jpg': '.jpg',
469 'image/jpeg': '.jpg' 472 'image/jpeg': '.jpg'
470 }, 473 },
@@ -579,6 +582,7 @@ const STATIC_DOWNLOAD_PATHS = {
579 HLS_VIDEOS: '/download/streaming-playlists/hls/videos/' 582 HLS_VIDEOS: '/download/streaming-playlists/hls/videos/'
580} 583}
581const LAZY_STATIC_PATHS = { 584const LAZY_STATIC_PATHS = {
585 BANNERS: '/lazy-static/banners/',
582 AVATARS: '/lazy-static/avatars/', 586 AVATARS: '/lazy-static/avatars/',
583 PREVIEWS: '/lazy-static/previews/', 587 PREVIEWS: '/lazy-static/previews/',
584 VIDEO_CAPTIONS: '/lazy-static/video-captions/', 588 VIDEO_CAPTIONS: '/lazy-static/video-captions/',
@@ -594,8 +598,8 @@ const STATIC_MAX_AGE = {
594 598
595// Videos thumbnail size 599// Videos thumbnail size
596const THUMBNAILS_SIZE = { 600const THUMBNAILS_SIZE = {
597 width: 223, 601 width: 280,
598 height: 122, 602 height: 157,
599 minWidth: 150 603 minWidth: 150
600} 604}
601const PREVIEWS_SIZE = { 605const PREVIEWS_SIZE = {
@@ -603,9 +607,15 @@ const PREVIEWS_SIZE = {
603 height: 480, 607 height: 480,
604 minWidth: 400 608 minWidth: 400
605} 609}
606const AVATARS_SIZE = { 610const ACTOR_IMAGES_SIZE = {
607 width: 120, 611 AVATARS: {
608 height: 120 612 width: 120,
613 height: 120
614 },
615 BANNERS: {
616 width: 1920,
617 height: 317 // 6/1 ratio
618 }
609} 619}
610 620
611const EMBED_SIZE = { 621const EMBED_SIZE = {
@@ -633,7 +643,7 @@ const LRU_CACHE = {
633 USER_TOKENS: { 643 USER_TOKENS: {
634 MAX_SIZE: 1000 644 MAX_SIZE: 1000
635 }, 645 },
636 AVATAR_STATIC: { 646 ACTOR_IMAGE_STATIC: {
637 MAX_SIZE: 500 647 MAX_SIZE: 500
638 } 648 }
639} 649}
@@ -670,7 +680,7 @@ const MEMOIZE_LENGTH = {
670} 680}
671 681
672const QUEUE_CONCURRENCY = { 682const QUEUE_CONCURRENCY = {
673 AVATAR_PROCESS_IMAGE: 3 683 ACTOR_PROCESS_IMAGE: 3
674} 684}
675 685
676const REDUNDANCY = { 686const REDUNDANCY = {
@@ -753,7 +763,7 @@ if (isTestInstance() === true) {
753 ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL = 10 * 1000 // 10 seconds 763 ACTIVITY_PUB.VIDEO_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
754 ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL = 10 * 1000 // 10 seconds 764 ACTIVITY_PUB.VIDEO_PLAYLIST_REFRESH_INTERVAL = 10 * 1000 // 10 seconds
755 765
756 CONSTRAINTS_FIELDS.ACTORS.AVATAR.FILE_SIZE.max = 100 * 1024 // 100KB 766 CONSTRAINTS_FIELDS.ACTORS.IMAGE.FILE_SIZE.max = 100 * 1024 // 100KB
757 CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max = 400 * 1024 // 400KB 767 CONSTRAINTS_FIELDS.VIDEOS.IMAGE.FILE_SIZE.max = 400 * 1024 // 400KB
758 768
759 SCHEDULER_INTERVALS_MS.actorFollowScores = 1000 769 SCHEDULER_INTERVALS_MS.actorFollowScores = 1000
@@ -763,6 +773,7 @@ if (isTestInstance() === true) {
763 SCHEDULER_INTERVALS_MS.updateVideos = 5000 773 SCHEDULER_INTERVALS_MS.updateVideos = 5000
764 SCHEDULER_INTERVALS_MS.autoFollowIndexInstances = 5000 774 SCHEDULER_INTERVALS_MS.autoFollowIndexInstances = 5000
765 SCHEDULER_INTERVALS_MS.updateInboxStats = 5000 775 SCHEDULER_INTERVALS_MS.updateInboxStats = 5000
776 SCHEDULER_INTERVALS_MS.checkPeerTubeVersion = 2000
766 REPEAT_JOBS['videos-views'] = { every: 5000 } 777 REPEAT_JOBS['videos-views'] = { every: 5000 }
767 REPEAT_JOBS['activitypub-cleaner'] = { every: 5000 } 778 REPEAT_JOBS['activitypub-cleaner'] = { every: 5000 }
768 779
@@ -813,7 +824,7 @@ export {
813 SEARCH_INDEX, 824 SEARCH_INDEX,
814 HLS_REDUNDANCY_DIRECTORY, 825 HLS_REDUNDANCY_DIRECTORY,
815 P2P_MEDIA_LOADER_PEER_VERSION, 826 P2P_MEDIA_LOADER_PEER_VERSION,
816 AVATARS_SIZE, 827 ACTOR_IMAGES_SIZE,
817 ACCEPT_HEADERS, 828 ACCEPT_HEADERS,
818 BCRYPT_SALT_SIZE, 829 BCRYPT_SALT_SIZE,
819 TRACKER_RATE_LIMITS, 830 TRACKER_RATE_LIMITS,
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index 243795e60..edf12bc41 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -1,7 +1,7 @@
1import { TrackerModel } from '@server/models/server/tracker'
2import { VideoTrackerModel } from '@server/models/server/video-tracker'
3import { QueryTypes, Transaction } from 'sequelize' 1import { QueryTypes, Transaction } from 'sequelize'
4import { Sequelize as SequelizeTypescript } from 'sequelize-typescript' 2import { Sequelize as SequelizeTypescript } from 'sequelize-typescript'
3import { TrackerModel } from '@server/models/server/tracker'
4import { VideoTrackerModel } from '@server/models/server/video-tracker'
5import { isTestInstance } from '../helpers/core-utils' 5import { isTestInstance } from '../helpers/core-utils'
6import { logger } from '../helpers/logger' 6import { logger } from '../helpers/logger'
7import { AbuseModel } from '../models/abuse/abuse' 7import { AbuseModel } from '../models/abuse/abuse'
@@ -11,6 +11,7 @@ import { VideoCommentAbuseModel } from '../models/abuse/video-comment-abuse'
11import { AccountModel } from '../models/account/account' 11import { AccountModel } from '../models/account/account'
12import { AccountBlocklistModel } from '../models/account/account-blocklist' 12import { AccountBlocklistModel } from '../models/account/account-blocklist'
13import { AccountVideoRateModel } from '../models/account/account-video-rate' 13import { AccountVideoRateModel } from '../models/account/account-video-rate'
14import { ActorImageModel } from '../models/account/actor-image'
14import { UserModel } from '../models/account/user' 15import { UserModel } from '../models/account/user'
15import { UserNotificationModel } from '../models/account/user-notification' 16import { UserNotificationModel } from '../models/account/user-notification'
16import { UserNotificationSettingModel } from '../models/account/user-notification-setting' 17import { UserNotificationSettingModel } from '../models/account/user-notification-setting'
@@ -18,7 +19,6 @@ import { UserVideoHistoryModel } from '../models/account/user-video-history'
18import { ActorModel } from '../models/activitypub/actor' 19import { ActorModel } from '../models/activitypub/actor'
19import { ActorFollowModel } from '../models/activitypub/actor-follow' 20import { ActorFollowModel } from '../models/activitypub/actor-follow'
20import { ApplicationModel } from '../models/application/application' 21import { ApplicationModel } from '../models/application/application'
21import { AvatarModel } from '../models/avatar/avatar'
22import { OAuthClientModel } from '../models/oauth/oauth-client' 22import { OAuthClientModel } from '../models/oauth/oauth-client'
23import { OAuthTokenModel } from '../models/oauth/oauth-token' 23import { OAuthTokenModel } from '../models/oauth/oauth-token'
24import { VideoRedundancyModel } from '../models/redundancy/video-redundancy' 24import { VideoRedundancyModel } from '../models/redundancy/video-redundancy'
@@ -85,7 +85,7 @@ const sequelizeTypescript = new SequelizeTypescript({
85 newMessage += ' in ' + benchmark + 'ms' 85 newMessage += ' in ' + benchmark + 'ms'
86 } 86 }
87 87
88 logger.debug(newMessage, { sql: message }) 88 logger.debug(newMessage, { sql: message, tags: [ 'sql' ] })
89 } 89 }
90}) 90})
91 91
@@ -104,7 +104,7 @@ async function initDatabaseModels (silent: boolean) {
104 ApplicationModel, 104 ApplicationModel,
105 ActorModel, 105 ActorModel,
106 ActorFollowModel, 106 ActorFollowModel,
107 AvatarModel, 107 ActorImageModel,
108 AccountModel, 108 AccountModel,
109 OAuthClientModel, 109 OAuthClientModel,
110 OAuthTokenModel, 110 OAuthTokenModel,
diff --git a/server/initializers/migrations/0610-views-index.ts b/server/initializers/migrations/0610-views-index copy.ts
index 02ee21172..02ee21172 100644
--- a/server/initializers/migrations/0610-views-index.ts
+++ b/server/initializers/migrations/0610-views-index copy.ts
diff --git a/server/initializers/migrations/0615-latest-versions-notification-settings.ts b/server/initializers/migrations/0615-latest-versions-notification-settings.ts
new file mode 100644
index 000000000..86bf56009
--- /dev/null
+++ b/server/initializers/migrations/0615-latest-versions-notification-settings.ts
@@ -0,0 +1,44 @@
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 {
10 const notificationSettingColumns = [ 'newPeerTubeVersion', 'newPluginVersion' ]
11
12 for (const column of notificationSettingColumns) {
13 const data = {
14 type: Sequelize.INTEGER,
15 defaultValue: null,
16 allowNull: true
17 }
18 await utils.queryInterface.addColumn('userNotificationSetting', column, data)
19 }
20
21 {
22 const query = 'UPDATE "userNotificationSetting" SET "newPeerTubeVersion" = 3, "newPluginVersion" = 1'
23 await utils.sequelize.query(query)
24 }
25
26 for (const column of notificationSettingColumns) {
27 const data = {
28 type: Sequelize.INTEGER,
29 defaultValue: null,
30 allowNull: false
31 }
32 await utils.queryInterface.changeColumn('userNotificationSetting', column, data)
33 }
34 }
35}
36
37function down (options) {
38 throw new Error('Not implemented.')
39}
40
41export {
42 up,
43 down
44}
diff --git a/server/initializers/migrations/0620-latest-versions-application.ts b/server/initializers/migrations/0620-latest-versions-application.ts
new file mode 100644
index 000000000..a689b18fc
--- /dev/null
+++ b/server/initializers/migrations/0620-latest-versions-application.ts
@@ -0,0 +1,27 @@
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
10 {
11 const data = {
12 type: Sequelize.STRING,
13 defaultValue: null,
14 allowNull: true
15 }
16 await utils.queryInterface.addColumn('application', 'latestPeerTubeVersion', data)
17 }
18}
19
20function down (options) {
21 throw new Error('Not implemented.')
22}
23
24export {
25 up,
26 down
27}
diff --git a/server/initializers/migrations/0625-latest-versions-notification.ts b/server/initializers/migrations/0625-latest-versions-notification.ts
new file mode 100644
index 000000000..77f395ce4
--- /dev/null
+++ b/server/initializers/migrations/0625-latest-versions-notification.ts
@@ -0,0 +1,26 @@
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
10 {
11 await utils.sequelize.query(`
12 ALTER TABLE "userNotification"
13 ADD COLUMN "applicationId" INTEGER REFERENCES "application" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
14 ADD COLUMN "pluginId" INTEGER REFERENCES "plugin" ("id") ON DELETE SET NULL ON UPDATE CASCADE
15 `)
16 }
17}
18
19function down (options) {
20 throw new Error('Not implemented.')
21}
22
23export {
24 up,
25 down
26}
diff --git a/server/initializers/migrations/0630-banner.ts b/server/initializers/migrations/0630-banner.ts
new file mode 100644
index 000000000..5766bb171
--- /dev/null
+++ b/server/initializers/migrations/0630-banner.ts
@@ -0,0 +1,50 @@
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
10 {
11 await utils.sequelize.query(`ALTER TABLE "avatar" RENAME to "actorImage"`)
12 }
13
14 {
15 const data = {
16 type: Sequelize.INTEGER,
17 defaultValue: null,
18 allowNull: true
19 }
20 await utils.queryInterface.addColumn('actorImage', 'type', data)
21 }
22
23 {
24 await utils.sequelize.query(`UPDATE "actorImage" SET "type" = 1`)
25 }
26
27 {
28 const data = {
29 type: Sequelize.INTEGER,
30 defaultValue: null,
31 allowNull: false
32 }
33 await utils.queryInterface.changeColumn('actorImage', 'type', data)
34 }
35
36 {
37 await utils.sequelize.query(
38 `ALTER TABLE "actor" ADD COLUMN "bannerId" INTEGER REFERENCES "actorImage" ("id") ON DELETE SET NULL ON UPDATE CASCADE`
39 )
40 }
41}
42
43function down (options) {
44 throw new Error('Not implemented.')
45}
46
47export {
48 up,
49 down
50}
diff --git a/server/initializers/migrations/0635-actor-image-size.ts b/server/initializers/migrations/0635-actor-image-size.ts
new file mode 100644
index 000000000..d7c5da8c3
--- /dev/null
+++ b/server/initializers/migrations/0635-actor-image-size.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 {
10 const data = {
11 type: Sequelize.INTEGER,
12 defaultValue: null,
13 allowNull: true
14 }
15 await utils.queryInterface.addColumn('actorImage', 'height', data)
16 }
17
18 {
19 const data = {
20 type: Sequelize.INTEGER,
21 defaultValue: null,
22 allowNull: true
23 }
24 await utils.queryInterface.addColumn('actorImage', 'width', data)
25 }
26}
27
28function down (options) {
29 throw new Error('Not implemented.')
30}
31
32export {
33 up,
34 down
35}