fix: Remove nullable on teams.name column (#9890)

* fix: Remove nullable on teams.name column

* Add test
This commit is contained in:
Tom Moor
2025-08-10 14:02:01 -04:00
committed by GitHub
parent c2f84466df
commit c5cd4d9335
2 changed files with 34 additions and 0 deletions
@@ -0,0 +1,23 @@
"use strict";
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
// Update any NULL team names to "Wiki" before removing nullable constraint
await queryInterface.sequelize.query(
`UPDATE teams SET name = 'Wiki' WHERE name IS NULL;`
);
await queryInterface.changeColumn("teams", "name", {
type: Sequelize.STRING,
allowNull: false,
});
},
async down(queryInterface, Sequelize) {
await queryInterface.changeColumn("teams", "name", {
type: Sequelize.STRING,
allowNull: true,
});
},
};
+11
View File
@@ -225,6 +225,17 @@ describe("#team.update", () => {
expect(res.status).toEqual(401);
});
it("should not allow setting team name to null", async () => {
const admin = await buildAdmin();
const res = await server.post("/api/team.update", {
body: {
token: admin.getJwtToken(),
name: null,
},
});
expect(res.status).toEqual(400);
});
it("should update default collection", async () => {
const team = await buildTeam();
const admin = await buildAdmin({ teamId: team.id });