mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
fix: Remove nullable on teams.name column (#9890)
* fix: Remove nullable on teams.name column * Add test
This commit is contained in:
@@ -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,
|
||||
});
|
||||
},
|
||||
};
|
||||
@@ -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 });
|
||||
|
||||
Reference in New Issue
Block a user