From d23e6a1c97a6ae3ca8d340a8c9adad268a5be57e Mon Sep 17 00:00:00 2001 From: BRAINS YUM <43896676+McFlat@users.noreply.github.com> Date: Fri, 19 Oct 2018 01:54:01 -0500 Subject: Feature/description support fields length 1000 (#1267) * fix migrations to not use config constant values as it can introduce bugs later when they change; (fixes #1259) remove constant fields imports from migrations * add migrations to update description and support fields to 1000 (fixes #1258) * fix client/server account and video_channel description/support fields to be max len 1000 (fixes #1258); fix test Should fail with a too long description; fix test Should fail with a long description; fix test Should fail with a long description; Remove USER.SUPPORT from constants since that field no longer exists; null not false, in migrations/0280-description-support.ts; video support field 1000, oops; * rename migration 0280-description-support.ts -> 0285-description-support.ts; update video support maxlength text --- server/initializers/migrations/0120-video-null.ts | 3 +- server/initializers/migrations/0195-support.ts | 9 ++-- .../initializers/migrations/0245-user-blocked.ts | 3 +- .../migrations/0250-video-abuse-state.ts | 3 +- .../migrations/0255-video-blacklist-reason.ts | 3 +- .../migrations/0260-upload-quota-daily.ts | 1 - .../migrations/0285-description-support.ts | 53 ++++++++++++++++++++++ 7 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 server/initializers/migrations/0285-description-support.ts (limited to 'server/initializers/migrations') diff --git a/server/initializers/migrations/0120-video-null.ts b/server/initializers/migrations/0120-video-null.ts index 63f3984dd..6d253f04f 100644 --- a/server/initializers/migrations/0120-video-null.ts +++ b/server/initializers/migrations/0120-video-null.ts @@ -1,5 +1,4 @@ import * as Sequelize from 'sequelize' -import { CONSTRAINTS_FIELDS } from '../constants' async function up (utils: { transaction: Sequelize.Transaction, @@ -28,7 +27,7 @@ async function up (utils: { { const data = { - type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max), + type: Sequelize.STRING(10000), allowNull: true, defaultValue: null } diff --git a/server/initializers/migrations/0195-support.ts b/server/initializers/migrations/0195-support.ts index 8722a5f22..3b9eabe79 100644 --- a/server/initializers/migrations/0195-support.ts +++ b/server/initializers/migrations/0195-support.ts @@ -1,5 +1,4 @@ import * as Sequelize from 'sequelize' -import { CONSTRAINTS_FIELDS } from '../index' async function up (utils: { transaction: Sequelize.Transaction, @@ -8,7 +7,7 @@ async function up (utils: { }): Promise { { const data = { - type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.SUPPORT.max), + type: Sequelize.STRING(500), allowNull: true, defaultValue: null } @@ -17,7 +16,7 @@ async function up (utils: { { const data = { - type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_CHANNELS.SUPPORT.max), + type: Sequelize.STRING(500), allowNull: true, defaultValue: null } @@ -26,7 +25,7 @@ async function up (utils: { { const data = { - type: Sequelize.STRING(CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max), + type: Sequelize.STRING(250), allowNull: true, defaultValue: null } @@ -35,7 +34,7 @@ async function up (utils: { { const data = { - type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEOS.DESCRIPTION.max), + type: Sequelize.STRING(10000), allowNull: true, defaultValue: null } diff --git a/server/initializers/migrations/0245-user-blocked.ts b/server/initializers/migrations/0245-user-blocked.ts index 5a04ecd2b..19c7d5b9c 100644 --- a/server/initializers/migrations/0245-user-blocked.ts +++ b/server/initializers/migrations/0245-user-blocked.ts @@ -1,5 +1,4 @@ import * as Sequelize from 'sequelize' -import { CONSTRAINTS_FIELDS } from '../constants' async function up (utils: { transaction: Sequelize.Transaction @@ -31,7 +30,7 @@ async function up (utils: { { const data = { - type: Sequelize.STRING(CONSTRAINTS_FIELDS.USERS.BLOCKED_REASON.max), + type: Sequelize.STRING(250), allowNull: true, defaultValue: null } diff --git a/server/initializers/migrations/0250-video-abuse-state.ts b/server/initializers/migrations/0250-video-abuse-state.ts index acb668ae1..50de25182 100644 --- a/server/initializers/migrations/0250-video-abuse-state.ts +++ b/server/initializers/migrations/0250-video-abuse-state.ts @@ -1,5 +1,4 @@ import * as Sequelize from 'sequelize' -import { CONSTRAINTS_FIELDS } from '../constants' import { VideoAbuseState } from '../../../shared/models/videos' async function up (utils: { @@ -32,7 +31,7 @@ async function up (utils: { { const data = { - type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_ABUSES.MODERATION_COMMENT.max), + type: Sequelize.STRING(300), allowNull: true, defaultValue: null } diff --git a/server/initializers/migrations/0255-video-blacklist-reason.ts b/server/initializers/migrations/0255-video-blacklist-reason.ts index a380e620e..69d6efb9e 100644 --- a/server/initializers/migrations/0255-video-blacklist-reason.ts +++ b/server/initializers/migrations/0255-video-blacklist-reason.ts @@ -1,5 +1,4 @@ import * as Sequelize from 'sequelize' -import { CONSTRAINTS_FIELDS } from '../constants' import { VideoAbuseState } from '../../../shared/models/videos' async function up (utils: { @@ -10,7 +9,7 @@ async function up (utils: { { const data = { - type: Sequelize.STRING(CONSTRAINTS_FIELDS.VIDEO_BLACKLIST.REASON.max), + type: Sequelize.STRING(300), allowNull: true, defaultValue: null } diff --git a/server/initializers/migrations/0260-upload-quota-daily.ts b/server/initializers/migrations/0260-upload-quota-daily.ts index d25154ba6..cbbe391ef 100644 --- a/server/initializers/migrations/0260-upload-quota-daily.ts +++ b/server/initializers/migrations/0260-upload-quota-daily.ts @@ -1,5 +1,4 @@ import * as Sequelize from 'sequelize' -import { CONSTRAINTS_FIELDS } from '../constants' async function up (utils: { transaction: Sequelize.Transaction diff --git a/server/initializers/migrations/0285-description-support.ts b/server/initializers/migrations/0285-description-support.ts new file mode 100644 index 000000000..85ef4ef39 --- /dev/null +++ b/server/initializers/migrations/0285-description-support.ts @@ -0,0 +1,53 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction, + queryInterface: Sequelize.QueryInterface, + sequelize: Sequelize.Sequelize, + db: any +}): Promise { + { + const data = { + type: Sequelize.STRING(1000), + allowNull: true, + defaultValue: null + } + await utils.queryInterface.changeColumn('video', 'support', data) + } + + { + const data = { + type: Sequelize.STRING(1000), + allowNull: true, + defaultValue: null + } + await utils.queryInterface.changeColumn('videoChannel', 'support', data) + } + + { + const data = { + type: Sequelize.STRING(1000), + allowNull: true, + defaultValue: null + } + await utils.queryInterface.changeColumn('videoChannel', 'description', data) + } + + { + const data = { + type: Sequelize.STRING(1000), + allowNull: true, + defaultValue: null + } + await utils.queryInterface.changeColumn('account', 'description', data) + } +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} -- cgit v1.2.3