import { AccountVideoRateModel } from '../models/account/account-video-rate'
import { UserModel } from '../models/account/user'
import { AccountVideoRateModel } from '../models/account/account-video-rate'
import { UserModel } from '../models/account/user'
import { ActorModel } from '../models/activitypub/actor'
import { ActorFollowModel } from '../models/activitypub/actor-follow'
import { ApplicationModel } from '../models/application/application'
import { AvatarModel } from '../models/avatar/avatar'
import { OAuthClientModel } from '../models/oauth/oauth-client'
import { OAuthTokenModel } from '../models/oauth/oauth-token'
import { ActorModel } from '../models/activitypub/actor'
import { ActorFollowModel } from '../models/activitypub/actor-follow'
import { ApplicationModel } from '../models/application/application'
import { AvatarModel } from '../models/avatar/avatar'
import { OAuthClientModel } from '../models/oauth/oauth-client'
import { OAuthTokenModel } from '../models/oauth/oauth-token'
import { VideoChannelModel } from '../models/video/video-channel'
import { VideoCommentModel } from '../models/video/video-comment'
import { VideoFileModel } from '../models/video/video-file'
import { VideoChannelModel } from '../models/video/video-channel'
import { VideoCommentModel } from '../models/video/video-comment'
import { VideoFileModel } from '../models/video/video-file'
-import { CONFIG } from './constants'
-import { ScheduleVideoUpdateModel } from '../models/video/schedule-video-update'
-import { VideoCaptionModel } from '../models/video/video-caption'
+import { VideoViewModel } from '../models/video/video-view'
+import { CONFIG } from './config'
- isolationLevel: SequelizeTypescript.Transaction.ISOLATION_LEVELS.SERIALIZABLE,
- operatorsAliases: false,
+ isolationLevel: Transaction.ISOLATION_LEVELS.SERIALIZABLE,
logging: (message: string, benchmark: number) => {
if (process.env.NODE_DB_LOG === 'false') return
logging: (message: string, benchmark: number) => {
if (process.env.NODE_DB_LOG === 'false') return
- ScheduleVideoUpdateModel
+ ScheduleVideoUpdateModel,
+ VideoImportModel,
+ VideoViewModel,
+ VideoRedundancyModel,
+ UserVideoHistoryModel,
+ AccountBlocklistModel,
+ ServerBlocklistModel,
+ UserNotificationModel,
+ UserNotificationSettingModel,
+ VideoStreamingPlaylistModel,
+ VideoPlaylistModel,
+ VideoPlaylistElementModel,
+ ThumbnailModel,
+ PluginModel
// ---------------------------------------------------------------------------
async function checkPostgresExtensions () {
// ---------------------------------------------------------------------------
async function checkPostgresExtensions () {
- for (const extension of extensions) {
- const query = `SELECT true AS enabled FROM pg_available_extensions WHERE name = '${extension}' AND installed_version IS NOT NULL;`
- const [ res ] = await sequelizeTypescript.query(query, { raw: true })
+ return Promise.all(promises)
+}
+
+async function checkPostgresExtension (extension: string) {
+ const query = `SELECT 1 FROM pg_available_extensions WHERE name = '${extension}' AND installed_version IS NOT NULL;`
+ const options = {
+ type: QueryTypes.SELECT as QueryTypes.SELECT,
+ raw: true
+ }
+
+ const res = await sequelizeTypescript.query<object>(query, options)
- if (!res || res.length === 0 || res[ 0 ][ 'enabled' ] !== true) {
- // Try to create the extension ourself
- try {
- await sequelizeTypescript.query(`CREATE EXTENSION ${extension};`, { raw: true })
+ if (!res || res.length === 0) {
+ // Try to create the extension ourselves
+ try {
+ await sequelizeTypescript.query(`CREATE EXTENSION ${extension};`, { raw: true })
- } catch {
- const errorMessage = `You need to enable ${extension} extension in PostgreSQL. ` +
- `You can do so by running 'CREATE EXTENSION ${extension};' as a PostgreSQL super user in ${CONFIG.DATABASE.DBNAME} database.`
- throw new Error(errorMessage)
- }
+ } catch {
+ const errorMessage = `You need to enable ${extension} extension in PostgreSQL. ` +
+ `You can do so by running 'CREATE EXTENSION ${extension};' as a PostgreSQL super user in ${CONFIG.DATABASE.DBNAME} database.`
+ throw new Error(errorMessage)