mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 03:27:05 -04:00
feat: add initial database migration
Signed-off-by: David Mehren <git@herrmehren.de>
This commit is contained in:
parent
09698579a7
commit
f8f198f9c9
7 changed files with 1082 additions and 5 deletions
28
backend/src/ormconfig.ts
Normal file
28
backend/src/ormconfig.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
import { AppModule } from './app.module';
|
||||
import { AppConfig } from './config/app.config';
|
||||
import { Loglevel } from './config/loglevel.enum';
|
||||
import { ConsoleLoggerService } from './logger/console-logger.service';
|
||||
|
||||
async function buildDataSource(): Promise<DataSource> {
|
||||
// We create a new app instance to let it discover entities
|
||||
const app = await NestFactory.create<NestExpressApplication>(AppModule, {
|
||||
logger: new ConsoleLoggerService({ loglevel: Loglevel.TRACE } as AppConfig),
|
||||
});
|
||||
const dataSource = app.get(DataSource);
|
||||
|
||||
// The migration CLI does not want an existing connection
|
||||
await dataSource.destroy();
|
||||
|
||||
return dataSource;
|
||||
}
|
||||
|
||||
export default buildDataSource();
|
Loading…
Add table
Add a link
Reference in a new issue