diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-18 11:28:17 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-24 16:26:20 +0200 |
commit | 1735c825726edaa0af5035cb6cbb0cc0db502c6d (patch) | |
tree | 7bbb442f2cb4d7be58a4e08d87f5974403a3047c /server/initializers/database.ts | |
parent | e8bafea35bc930cb8ac5b2d521a188642a1adffe (diff) | |
download | PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.gz PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.tar.zst PeerTube-1735c825726edaa0af5035cb6cbb0cc0db502c6d.zip |
Update sequelize
Diffstat (limited to 'server/initializers/database.ts')
-rw-r--r-- | server/initializers/database.ts | 13 |
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 | |||
37 | import { VideoPlaylistModel } from '../models/video/video-playlist' | 37 | import { VideoPlaylistModel } from '../models/video/video-playlist' |
38 | import { VideoPlaylistElementModel } from '../models/video/video-playlist-element' | 38 | import { VideoPlaylistElementModel } from '../models/video/video-playlist-element' |
39 | import { ThumbnailModel } from '../models/video/thumbnail' | 39 | import { ThumbnailModel } from '../models/video/thumbnail' |
40 | import { QueryTypes, Transaction } from 'sequelize' | ||
40 | 41 | ||
41 | require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string | 42 | require('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 | ||
142 | async function checkPostgresExtension (extension: string) { | 142 | async 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 | ||