aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-30 10:16:27 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-10-30 10:16:27 +0100
commit9567011bf01f36c7f796ac1e0f1fb12c71635e53 (patch)
treebec3ed173767cff031ed0a84231d6dd50e792569 /server/initializers
parent757f0da370a992cf07afd20d3829b2748c76cc15 (diff)
downloadPeerTube-9567011bf01f36c7f796ac1e0f1fb12c71635e53.tar.gz
PeerTube-9567011bf01f36c7f796ac1e0f1fb12c71635e53.tar.zst
PeerTube-9567011bf01f36c7f796ac1e0f1fb12c71635e53.zip
Add lazy description on server
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts5
-rw-r--r--server/initializers/database.ts9
-rw-r--r--server/initializers/migrations/0090-videos-description.ts25
3 files changed, 35 insertions, 4 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 6dc9737d2..adccb9f41 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -15,7 +15,7 @@ import {
15 15
16// --------------------------------------------------------------------------- 16// ---------------------------------------------------------------------------
17 17
18const LAST_MIGRATION_VERSION = 85 18const LAST_MIGRATION_VERSION = 90
19 19
20// --------------------------------------------------------------------------- 20// ---------------------------------------------------------------------------
21 21
@@ -122,7 +122,8 @@ const CONSTRAINTS_FIELDS = {
122 }, 122 },
123 VIDEOS: { 123 VIDEOS: {
124 NAME: { min: 3, max: 120 }, // Length 124 NAME: { min: 3, max: 120 }, // Length
125 DESCRIPTION: { min: 3, max: 250 }, // Length 125 TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length
126 DESCRIPTION: { min: 3, max: 3000 }, // Length
126 EXTNAME: [ '.mp4', '.ogv', '.webm' ], 127 EXTNAME: [ '.mp4', '.ogv', '.webm' ],
127 INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2 128 INFO_HASH: { min: 40, max: 40 }, // Length, info hash is 20 bytes length but we represent it in hexadecimal so 20 * 2
128 DURATION: { min: 1, max: 7200 }, // Number 129 DURATION: { min: 1, max: 7200 }, // Number
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index dfad01581..141566c3a 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -84,9 +84,14 @@ database.init = async (silent: boolean) => {
84 const filePaths = await getModelFiles(modelDirectory) 84 const filePaths = await getModelFiles(modelDirectory)
85 85
86 for (const filePath of filePaths) { 86 for (const filePath of filePaths) {
87 const model = sequelize.import(filePath) 87 try {
88 const model = sequelize.import(filePath)
88 89
89 database[model['name']] = model 90 database[model['name']] = model
91 } catch (err) {
92 logger.error('Cannot import database model %s.', filePath, err)
93 process.exit(0)
94 }
90 } 95 }
91 96
92 for (const modelName of Object.keys(database)) { 97 for (const modelName of Object.keys(database)) {
diff --git a/server/initializers/migrations/0090-videos-description.ts b/server/initializers/migrations/0090-videos-description.ts
new file mode 100644
index 000000000..6f98dcade
--- /dev/null
+++ b/server/initializers/migrations/0090-videos-description.ts
@@ -0,0 +1,25 @@
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.STRING(3000),
13 allowNull: false
14 }
15 await q.changeColumn('Videos', 'description', data)
16}
17
18function down (options) {
19 throw new Error('Not implemented.')
20}
21
22export {
23 up,
24 down
25}