diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-12-11 11:06:32 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-12-11 11:06:32 +0100 |
commit | fada8d75550dc7365f7e18ee1569b9406251d660 (patch) | |
tree | db9dc01c18693824f83fce5020f4c1f3ae7c0865 /server/initializers | |
parent | 492fd28167f770d79a430fc57451b5a9e075d8e7 (diff) | |
parent | c2830fa8f84f61462098bf36add824f89436dfa9 (diff) | |
download | PeerTube-fada8d75550dc7365f7e18ee1569b9406251d660.tar.gz PeerTube-fada8d75550dc7365f7e18ee1569b9406251d660.tar.zst PeerTube-fada8d75550dc7365f7e18ee1569b9406251d660.zip |
Merge branch 'feature/design' into develop
Diffstat (limited to 'server/initializers')
-rw-r--r-- | server/initializers/constants.ts | 13 | ||||
-rw-r--r-- | server/initializers/database.ts | 2 | ||||
-rw-r--r-- | server/initializers/migrations/0115-account-avatar.ts | 31 | ||||
-rw-r--r-- | server/initializers/migrations/0120-video-null.ts | 47 |
4 files changed, 86 insertions, 7 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index e3d779456..7be7a5f95 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -14,7 +14,7 @@ import { FollowState } from '../../shared/models/accounts/follow.model' | |||
14 | 14 | ||
15 | // --------------------------------------------------------------------------- | 15 | // --------------------------------------------------------------------------- |
16 | 16 | ||
17 | const LAST_MIGRATION_VERSION = 110 | 17 | const LAST_MIGRATION_VERSION = 120 |
18 | 18 | ||
19 | // --------------------------------------------------------------------------- | 19 | // --------------------------------------------------------------------------- |
20 | 20 | ||
@@ -25,11 +25,6 @@ const API_VERSION = 'v1' | |||
25 | const PAGINATION_COUNT_DEFAULT = 15 | 25 | const PAGINATION_COUNT_DEFAULT = 15 |
26 | 26 | ||
27 | // Sortable columns per schema | 27 | // Sortable columns per schema |
28 | const SEARCHABLE_COLUMNS = { | ||
29 | VIDEOS: [ 'name', 'magnetUri', 'host', 'account', 'tags' ] | ||
30 | } | ||
31 | |||
32 | // Sortable columns per schema | ||
33 | const SORTABLE_COLUMNS = { | 28 | const SORTABLE_COLUMNS = { |
34 | USERS: [ 'id', 'username', 'createdAt' ], | 29 | USERS: [ 'id', 'username', 'createdAt' ], |
35 | JOBS: [ 'id', 'createdAt' ], | 30 | JOBS: [ 'id', 'createdAt' ], |
@@ -60,6 +55,7 @@ const CONFIG = { | |||
60 | PASSWORD: config.get<string>('database.password') | 55 | PASSWORD: config.get<string>('database.password') |
61 | }, | 56 | }, |
62 | STORAGE: { | 57 | STORAGE: { |
58 | AVATARS_DIR: join(root(), config.get<string>('storage.avatars')), | ||
63 | LOG_DIR: join(root(), config.get<string>('storage.logs')), | 59 | LOG_DIR: join(root(), config.get<string>('storage.logs')), |
64 | VIDEOS_DIR: join(root(), config.get<string>('storage.videos')), | 60 | VIDEOS_DIR: join(root(), config.get<string>('storage.videos')), |
65 | THUMBNAILS_DIR: join(root(), config.get<string>('storage.thumbnails')), | 61 | THUMBNAILS_DIR: join(root(), config.get<string>('storage.thumbnails')), |
@@ -105,6 +101,9 @@ const CONFIG = { | |||
105 | CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT | 101 | CONFIG.WEBSERVER.URL = CONFIG.WEBSERVER.SCHEME + '://' + CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT |
106 | CONFIG.WEBSERVER.HOST = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT | 102 | CONFIG.WEBSERVER.HOST = CONFIG.WEBSERVER.HOSTNAME + ':' + CONFIG.WEBSERVER.PORT |
107 | 103 | ||
104 | const AVATARS_DIR = { | ||
105 | ACCOUNT: join(CONFIG.STORAGE.AVATARS_DIR, 'account') | ||
106 | } | ||
108 | // --------------------------------------------------------------------------- | 107 | // --------------------------------------------------------------------------- |
109 | 108 | ||
110 | const CONSTRAINTS_FIELDS = { | 109 | const CONSTRAINTS_FIELDS = { |
@@ -356,7 +355,7 @@ export { | |||
356 | PREVIEWS_SIZE, | 355 | PREVIEWS_SIZE, |
357 | REMOTE_SCHEME, | 356 | REMOTE_SCHEME, |
358 | FOLLOW_STATES, | 357 | FOLLOW_STATES, |
359 | SEARCHABLE_COLUMNS, | 358 | AVATARS_DIR, |
360 | SERVER_ACCOUNT_NAME, | 359 | SERVER_ACCOUNT_NAME, |
361 | PRIVATE_RSA_KEY_SIZE, | 360 | PRIVATE_RSA_KEY_SIZE, |
362 | SORTABLE_COLUMNS, | 361 | SORTABLE_COLUMNS, |
diff --git a/server/initializers/database.ts b/server/initializers/database.ts index 90dbba5b9..bb95992e1 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts | |||
@@ -2,6 +2,7 @@ import { join } from 'path' | |||
2 | import { flattenDepth } from 'lodash' | 2 | import { flattenDepth } from 'lodash' |
3 | require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string | 3 | require('pg').defaults.parseInt8 = true // Avoid BIGINT to be converted to string |
4 | import * as Sequelize from 'sequelize' | 4 | import * as Sequelize from 'sequelize' |
5 | import { AvatarModel } from '../models/avatar' | ||
5 | 6 | ||
6 | import { CONFIG } from './constants' | 7 | import { CONFIG } from './constants' |
7 | // Do not use barrel, we need to load database first | 8 | // Do not use barrel, we need to load database first |
@@ -36,6 +37,7 @@ export type PeerTubeDatabase = { | |||
36 | init?: (silent: boolean) => Promise<void>, | 37 | init?: (silent: boolean) => Promise<void>, |
37 | 38 | ||
38 | Application?: ApplicationModel, | 39 | Application?: ApplicationModel, |
40 | Avatar?: AvatarModel, | ||
39 | Account?: AccountModel, | 41 | Account?: AccountModel, |
40 | Job?: JobModel, | 42 | Job?: JobModel, |
41 | OAuthClient?: OAuthClientModel, | 43 | OAuthClient?: OAuthClientModel, |
diff --git a/server/initializers/migrations/0115-account-avatar.ts b/server/initializers/migrations/0115-account-avatar.ts new file mode 100644 index 000000000..2b947ceda --- /dev/null +++ b/server/initializers/migrations/0115-account-avatar.ts | |||
@@ -0,0 +1,31 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { PeerTubeDatabase } from '../database' | ||
3 | |||
4 | async function up (utils: { | ||
5 | transaction: Sequelize.Transaction, | ||
6 | queryInterface: Sequelize.QueryInterface, | ||
7 | sequelize: Sequelize.Sequelize, | ||
8 | db: PeerTubeDatabase | ||
9 | }): Promise<void> { | ||
10 | await utils.db.Avatar.sync() | ||
11 | |||
12 | const data = { | ||
13 | type: Sequelize.INTEGER, | ||
14 | allowNull: true, | ||
15 | references: { | ||
16 | model: 'Avatars', | ||
17 | key: 'id' | ||
18 | }, | ||
19 | onDelete: 'CASCADE' | ||
20 | } | ||
21 | await utils.queryInterface.addColumn('Accounts', 'avatarId', data) | ||
22 | } | ||
23 | |||
24 | function down (options) { | ||
25 | throw new Error('Not implemented.') | ||
26 | } | ||
27 | |||
28 | export { | ||
29 | up, | ||
30 | down | ||
31 | } | ||
diff --git a/server/initializers/migrations/0120-video-null.ts b/server/initializers/migrations/0120-video-null.ts new file mode 100644 index 000000000..9130d10ee --- /dev/null +++ b/server/initializers/migrations/0120-video-null.ts | |||
@@ -0,0 +1,47 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | import { CONSTRAINTS_FIELDS } from '../constants' | ||
3 | import { PeerTubeDatabase } from '../database' | ||
4 | |||
5 | async function up (utils: { | ||
6 | transaction: Sequelize.Transaction, | ||
7 | queryInterface: Sequelize.QueryInterface, | ||
8 | sequelize: Sequelize.Sequelize, | ||
9 | db: PeerTubeDatabase | ||
10 | }): Promise<void> { | ||
11 | |||
12 | { | ||
13 | const data = { | ||
14 | type: Sequelize.INTEGER, | ||
15 | allowNull: true, | ||
16 | defaultValue: null | ||
17 | } | ||
18 | await utils.queryInterface.changeColumn('Videos', 'licence', data) | ||
19 | } | ||
20 | |||
21 | { | ||
22 | const data = { | ||
23 | type: Sequelize.INTEGER, | ||
24 | allowNull: true, | ||
25 | defaultValue: null | ||
26 | } | ||
27 | await utils.queryInterface.changeColumn('Videos', 'category', data) | ||
28 | } | ||
29 | |||
30 | { | ||
31 | const data = { | ||
32 | type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max), | ||
33 | allowNull: true, | ||
34 | defaultValue: null | ||
35 | } | ||
36 | await utils.queryInterface.changeColumn('Videos', 'description', data) | ||
37 | } | ||
38 | } | ||
39 | |||
40 | function down (options) { | ||
41 | throw new Error('Not implemented.') | ||
42 | } | ||
43 | |||
44 | export { | ||
45 | up, | ||
46 | down | ||
47 | } | ||