mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-06 17:41:52 -04:00
refactor(database): run knex migrations on startup
Co-authored-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Philip Molares <philip.molares@udo.edu> Signed-off-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
d67e44f540
commit
21a1f35281
85 changed files with 830 additions and 418 deletions
|
@ -5,17 +5,21 @@
|
|||
*/
|
||||
import {
|
||||
AuthProviderType,
|
||||
LoginUserInfoDto,
|
||||
REGEX_USERNAME,
|
||||
UserInfoDto,
|
||||
} from '@hedgedoc/commons';
|
||||
import { LoginUserInfoDto } from '@hedgedoc/commons';
|
||||
import {
|
||||
FieldNameUser,
|
||||
TableUser,
|
||||
TypeUpdateUser,
|
||||
User,
|
||||
} from '@hedgedoc/database';
|
||||
import { BadRequestException, Injectable } from '@nestjs/common';
|
||||
import { Knex } from 'knex';
|
||||
import { InjectConnection } from 'nest-knexjs';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { FieldNameUser, TableUser, User } from '../database/types';
|
||||
import { TypeUpdateUser } from '../database/types/user';
|
||||
import { GenericDBError, NotInDBError } from '../errors/errors';
|
||||
import { ConsoleLoggerService } from '../logger/console-logger.service';
|
||||
import { generateRandomName } from '../realtime/realtime-note/random-word-lists/name-randomizer';
|
||||
|
@ -209,11 +213,12 @@ export class UsersService {
|
|||
transaction?: Knex,
|
||||
): Promise<boolean> {
|
||||
const dbActor = transaction ? transaction : this.knex;
|
||||
const username = await dbActor(TableUser)
|
||||
const usernameResponse = await dbActor(TableUser)
|
||||
.select(FieldNameUser.username)
|
||||
.where(FieldNameUser.id, userId)
|
||||
.first();
|
||||
return username !== null && username !== undefined;
|
||||
const username = usernameResponse?.[FieldNameUser.username] ?? null;
|
||||
return username !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue