diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-15 14:46:26 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-15 15:29:07 +0100 |
commit | 2422c46b27790d94fd29a7092170cee5a1b56008 (patch) | |
tree | d5c1942ce20cadb27a551d87c789edfe92f5b105 /server/initializers | |
parent | 34cbef8c6cc912143a421413bdd832c4adcc556a (diff) | |
download | PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.gz PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.tar.zst PeerTube-2422c46b27790d94fd29a7092170cee5a1b56008.zip |
Implement support field in video and video channel
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/constants.ts | 7 | ||||
-rw-r--r-- | server/initializers/migrations/0195-support.ts | 53 |
2 files changed, 58 insertions, 2 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 91fbbde75..ac001bbc7 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -12,7 +12,7 @@ let config: IConfig = require('config') | |||
12 | 12 | ||
13 | // --------------------------------------------------------------------------- | 13 | // --------------------------------------------------------------------------- |
14 | 14 | ||
15 | const LAST_MIGRATION_VERSION = 190 | 15 | const LAST_MIGRATION_VERSION = 195 |
16 | 16 | ||
17 | // --------------------------------------------------------------------------- | 17 | // --------------------------------------------------------------------------- |
18 | 18 | ||
@@ -168,6 +168,7 @@ const CONSTRAINTS_FIELDS = { | |||
168 | USERS: { | 168 | USERS: { |
169 | USERNAME: { min: 3, max: 20 }, // Length | 169 | USERNAME: { min: 3, max: 20 }, // Length |
170 | PASSWORD: { min: 6, max: 255 }, // Length | 170 | PASSWORD: { min: 6, max: 255 }, // Length |
171 | DESCRIPTION: { min: 3, max: 250 }, // Length | ||
171 | VIDEO_QUOTA: { min: -1 } | 172 | VIDEO_QUOTA: { min: -1 } |
172 | }, | 173 | }, |
173 | VIDEO_ABUSES: { | 174 | VIDEO_ABUSES: { |
@@ -176,12 +177,14 @@ const CONSTRAINTS_FIELDS = { | |||
176 | VIDEO_CHANNELS: { | 177 | VIDEO_CHANNELS: { |
177 | NAME: { min: 3, max: 120 }, // Length | 178 | NAME: { min: 3, max: 120 }, // Length |
178 | DESCRIPTION: { min: 3, max: 250 }, // Length | 179 | DESCRIPTION: { min: 3, max: 250 }, // Length |
180 | SUPPORT: { min: 3, max: 300 }, // Length | ||
179 | URL: { min: 3, max: 2000 } // Length | 181 | URL: { min: 3, max: 2000 } // Length |
180 | }, | 182 | }, |
181 | VIDEOS: { | 183 | VIDEOS: { |
182 | NAME: { min: 3, max: 120 }, // Length | 184 | NAME: { min: 3, max: 120 }, // Length |
183 | TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length | 185 | TRUNCATED_DESCRIPTION: { min: 3, max: 250 }, // Length |
184 | DESCRIPTION: { min: 3, max: 3000 }, // Length | 186 | DESCRIPTION: { min: 3, max: 10000 }, // Length |
187 | SUPPORT: { min: 3, max: 300 }, // Length | ||
185 | IMAGE: { | 188 | IMAGE: { |
186 | EXTNAME: [ '.jpg', '.jpeg' ], | 189 | EXTNAME: [ '.jpg', '.jpeg' ], |
187 | FILE_SIZE: { | 190 | FILE_SIZE: { |
diff --git a/server/initializers/migrations/0195-support.ts b/server/initializers/migrations/0195-support.ts new file mode 100644 index 000000000..8722a5f22 --- /dev/null +++ b/server/initializers/migrations/0195-support.ts | |||
@@ -0,0 +1,53 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { CONSTRAINTS_FIELDS } from '../index' | ||
3 | |||
4 | async function up (utils: { | ||
5 | transaction: Sequelize.Transaction, | ||
6 | queryInterface: Sequelize.QueryInterface, | ||
7 | sequelize: Sequelize.Sequelize | ||
8 | }): Promise<void> { | ||
9 | { | ||
10 | const data = { | ||
11 | type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.SUPPORT.max), | ||
12 | allowNull: true, | ||
13 | defaultValue: null | ||
14 | } | ||
15 | await utils.queryInterface.addColumn('video', 'support', data) | ||
16 | } | ||
17 | |||
18 | { | ||
19 | const data = { | ||
20 | type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max), | ||
21 | allowNull: true, | ||
22 | defaultValue: null | ||
23 | } | ||
24 | await utils.queryInterface.addColumn('videoChannel', 'support', data) | ||
25 | } | ||
26 | |||
27 | { | ||
28 | const data = { | ||
29 | type: Sequelize.STRING(CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max), | ||
30 | allowNull: true, | ||
31 | defaultValue: null | ||
32 | } | ||
33 | await utils.queryInterface.addColumn('account', 'description', data) | ||
34 | } | ||
35 | |||
36 | { | ||
37 | const data = { | ||
38 | type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max), | ||
39 | allowNull: true, | ||
40 | defaultValue: null | ||
41 | } | ||
42 | await utils.queryInterface.changeColumn('video', 'description', data) | ||
43 | } | ||
44 | } | ||
45 | |||
46 | function down (options) { | ||
47 | throw new Error('Not implemented.') | ||
48 | } | ||
49 | |||
50 | export { | ||
51 | up, | ||
52 | down | ||
53 | } | ||