aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers/database.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/initializers/database.ts')
-rw-r--r--server/initializers/database.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index 8f237eb23..d1744d21f 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -37,6 +37,7 @@ import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-pla
37import { VideoPlaylistModel } from '../models/video/video-playlist' 37import { VideoPlaylistModel } from '../models/video/video-playlist'
38import { VideoPlaylistElementModel } from '../models/video/video-playlist-element' 38import { VideoPlaylistElementModel } from '../models/video/video-playlist-element'
39import { ThumbnailModel } from '../models/video/thumbnail' 39import { ThumbnailModel } from '../models/video/thumbnail'
40import { QueryTypes, Transaction } from 'sequelize'
40 41
41require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string 42require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string
42 43
@@ -58,8 +59,7 @@ const sequelizeTypescript = new SequelizeTypescript({
58 max: poolMax 59 max: poolMax
59 }, 60 },
60 benchmark: isTestInstance(), 61 benchmark: isTestInstance(),
61 isolationLevel: SequelizeTypescript.Transaction.ISOLATION_LEVELS.SERIALIZABLE, 62 isolationLevel: Transaction.ISOLATION_LEVELS.SERIALIZABLE,
62 operatorsAliases: false,
63 logging: (message: string, benchmark: number) => { 63 logging: (message: string, benchmark: number) => {
64 if (process.env.NODE_DB_LOG === 'false') return 64 if (process.env.NODE_DB_LOG === 'false') return
65 65
@@ -141,10 +141,15 @@ async function checkPostgresExtensions () {
141 141
142async function checkPostgresExtension (extension: string) { 142async function checkPostgresExtension (extension: string) {
143 const query = `SELECT true AS enabled FROM pg_available_extensions WHERE name = '${extension}' AND installed_version IS NOT NULL;` 143 const query = `SELECT true AS enabled FROM pg_available_extensions WHERE name = '${extension}' AND installed_version IS NOT NULL;`
144 const [ res ] = await sequelizeTypescript.query(query, { raw: true }) 144 const options = {
145 type: QueryTypes.SELECT as QueryTypes.SELECT,
146 raw: true
147 }
148
149 const res = await sequelizeTypescript.query<{ enabled: boolean }>(query, options)
145 150
146 if (!res || res.length === 0 || res[ 0 ][ 'enabled' ] !== true) { 151 if (!res || res.length === 0 || res[ 0 ][ 'enabled' ] !== true) {
147 // Try to create the extension ourself 152 // Try to create the extension ourselves
148 try { 153 try {
149 await sequelizeTypescript.query(`CREATE EXTENSION ${extension};`, { raw: true }) 154 await sequelizeTypescript.query(`CREATE EXTENSION ${extension};`, { raw: true })
150 155