From 047b17b479c66cb05254e6c25569d426ec765843 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 27 Sep 2022 23:14:03 -0400 Subject: [PATCH] fix: Increase possible length of user and team avatar urls --- .../20220928030442-fix-avatar-urls.js | 33 +++++++++++++++++++ server/models/Team.ts | 2 +- server/models/User.ts | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 server/migrations/20220928030442-fix-avatar-urls.js diff --git a/server/migrations/20220928030442-fix-avatar-urls.js b/server/migrations/20220928030442-fix-avatar-urls.js new file mode 100644 index 000000000..e2790898e --- /dev/null +++ b/server/migrations/20220928030442-fix-avatar-urls.js @@ -0,0 +1,33 @@ +'use strict'; + +module.exports = { + up: async (queryInterface, Sequelize) => { + await queryInterface.sequelize.transaction(async (transaction) => { + await queryInterface.changeColumn("users", "avatarUrl", { + type: Sequelize.STRING(4096), + allowNull: true, + transaction, + }); + await queryInterface.changeColumn("teams", "avatarUrl", { + type: Sequelize.STRING(4096), + allowNull: true, + transaction, + }); + }); + }, + + down: async (queryInterface, Sequelize) => { + await queryInterface.sequelize.transaction(async (transaction) => { + await queryInterface.changeColumn("users", "avatarUrl", { + type: Sequelize.STRING, + allowNull: true, + transaction, + }); + await queryInterface.changeColumn("teams", "avatarUrl", { + type: Sequelize.STRING, + allowNull: true, + transaction, + }); + }); + } +}; diff --git a/server/models/Team.ts b/server/models/Team.ts index 53a7dbf5a..11308ac6a 100644 --- a/server/models/Team.ts +++ b/server/models/Team.ts @@ -89,7 +89,7 @@ class Team extends ParanoidModel { @AllowNull @IsUrl - @Length({ max: 255, msg: "avatarUrl must be 255 characters or less" }) + @Length({ max: 4096, msg: "avatarUrl must be 4096 characters or less" }) @Column avatarUrl: string | null; diff --git a/server/models/User.ts b/server/models/User.ts index 3775b6b30..6241f30ff 100644 --- a/server/models/User.ts +++ b/server/models/User.ts @@ -170,7 +170,7 @@ class User extends ParanoidModel { @AllowNull @IsUrl - @Length({ max: 1000, msg: "avatarUrl must be less than 1000 characters" }) + @Length({ max: 4096, msg: "avatarUrl must be less than 4096 characters" }) @Column(DataType.STRING) get avatarUrl() { const original = this.getDataValue("avatarUrl");