Files
outline/server/migrations/20171225143838-set-admins.js
Tom Moor 15b1069bcc chore: Move to Typescript (#2783)
This PR moves the entire project to Typescript. Due to the ~1000 ignores this will lead to a messy codebase for a while, but the churn is worth it – all of those ignore comments are places that were never type-safe previously.

closes #1282
2021-11-29 06:40:55 -08:00

28 lines
641 B
JavaScript

module.exports = {
up: async (queryInterface, Sequelize) => {
const [teams, metaData] = await queryInterface.sequelize.query(
`SELECT * FROM teams`
);
const teamIds = teams.map((team) => team.id);
await Promise.all(
teamIds.map(async (teamId) => {
await queryInterface.sequelize.query(`
update users
set "isAdmin" = true
where id in (
select id
from users
where "teamId" = '${teamId}'
order by "createdAt" asc
limit 1
);
`);
})
);
},
down: async (queryInterface, Sequelize) => {
// no-op
},
};