From 241c3357d13ac2fb4c8ffca6469e575388c1fac5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 13 May 2019 14:37:30 +0200 Subject: [PATCH] Fix account description error --- server/initializers/constants.ts | 2 +- .../migrations/0375-account-description.ts | 25 +++++++++++++++++++ server/models/account/account.ts | 6 ++--- 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 server/initializers/migrations/0375-account-description.ts diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 3fce864bd..62778ae58 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 370 +const LAST_MIGRATION_VERSION = 375 // --------------------------------------------------------------------------- diff --git a/server/initializers/migrations/0375-account-description.ts b/server/initializers/migrations/0375-account-description.ts new file mode 100644 index 000000000..1258563fd --- /dev/null +++ b/server/initializers/migrations/0375-account-description.ts @@ -0,0 +1,25 @@ +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('account', 'description', data) +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} diff --git a/server/models/account/account.ts b/server/models/account/account.ts index c53312990..2b04acd86 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -3,7 +3,7 @@ import { BeforeDestroy, BelongsTo, Column, - CreatedAt, + CreatedAt, DataType, Default, DefaultScope, ForeignKey, @@ -26,7 +26,7 @@ import { VideoCommentModel } from '../video/video-comment' import { UserModel } from './user' import { AvatarModel } from '../avatar/avatar' import { VideoPlaylistModel } from '../video/video-playlist' -import { WEBSERVER } from '../../initializers/constants' +import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants' import { Op, Transaction, WhereOptions } from 'sequelize' export enum ScopeNames { @@ -91,7 +91,7 @@ export class AccountModel extends Model { @AllowNull(true) @Default(null) @Is('AccountDescription', value => throwIfNotValid(value, isAccountDescriptionValid, 'description', true)) - @Column + @Column(DataType.STRING(CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max)) description: string @CreatedAt -- 2.25.1