Fix account description error
authorChocobozzz <me@florianbigard.com>
Mon, 13 May 2019 12:37:30 +0000 (14:37 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 13 May 2019 12:37:30 +0000 (14:37 +0200)
server/initializers/constants.ts
server/initializers/migrations/0375-account-description.ts [new file with mode: 0644]
server/models/account/account.ts

index 3fce864bd41bebbf5cceb5155020712b4fad294c..62778ae58443c137cae02503f148336f49026735 100644 (file)
@@ -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 (file)
index 0000000..1258563
--- /dev/null
@@ -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<void> {
+  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
+}
index c53312990d7009e455fe711be7f13f45a12c962a..2b04acd863743d3a6e8c69462165741d83350ece 100644 (file)
@@ -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<AccountModel> {
   @AllowNull(true)
   @Default(null)
   @Is('AccountDescription', value => throwIfNotValid(value, isAccountDescriptionValid, 'description', true))
-  @Column
+  @Column(DataType.STRING(CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max))
   description: string
 
   @CreatedAt