diff --git a/server/src/app.ts b/server/src/app.ts index fa8275c..dbe430d 100644 --- a/server/src/app.ts +++ b/server/src/app.ts @@ -3,9 +3,10 @@ import { getLogger } from 'log4js'; import { createKoaServer, useContainer as routingUseContainer } from 'routing-controllers'; import { createSocketServer, useContainer as socketUseContainer } from 'socket-controllers'; import { Container } from 'typedi'; -import { useContainer as ormUseContainer, createConnection, getConnectionOptions } from 'typeorm'; +import { useContainer as ormUseContainer, createConnection, getConnectionOptions, getManager, getConnection } from 'typeorm'; import { config } from './config'; import { decorators } from './decorator'; +import { UserRoom } from './entity'; import './middleware/socket/AuthenitificationMiddleware'; const logger = getLogger('startup'); @@ -48,6 +49,15 @@ async function createServer() { await createConnection(connectionOptions); logger.info('TypeORM connection success'); + const result = await getConnection() + .createQueryBuilder() + .update(UserRoom) + .set({ isLeft: true }) + .where('isLeft is false') + .execute(); + + logger.info('Set `UserRoom`.`isLeft` to true: ', result.raw.affectedRows); + /** * We create a new koa server instance. * We could have also use useKoaServer here to attach controllers to an existing koa instance.