chore: reformat database schema files for readability
Applied consistent formatting and indentation across all schema files using Drizzle ORM to enhance code clarity and maintainability.
This commit is contained in:
@@ -6,28 +6,30 @@
|
||||
* is strictly prohibited.
|
||||
*/
|
||||
|
||||
import {Injectable, Logger, OnModuleDestroy, OnModuleInit} from "@nestjs/common";
|
||||
import {
|
||||
Injectable,
|
||||
Logger,
|
||||
OnModuleDestroy,
|
||||
OnModuleInit,
|
||||
} from "@nestjs/common";
|
||||
import { ConfigService } from "@nestjs/config";
|
||||
import { drizzle } from "drizzle-orm/node-postgres";
|
||||
import { migrate } from "drizzle-orm/node-postgres/migrator";
|
||||
import * as schema from "./schemas";
|
||||
import {Pool} from "pg";
|
||||
import { Pool } from "pg";
|
||||
|
||||
@Injectable()
|
||||
export class DatabaseService implements OnModuleInit, OnModuleDestroy {
|
||||
private readonly logger = new Logger(DatabaseService.name);
|
||||
private readonly pool!: Pool
|
||||
private readonly pool!: Pool;
|
||||
public readonly db: ReturnType<typeof drizzle>;
|
||||
|
||||
constructor(
|
||||
private configService: ConfigService
|
||||
) {
|
||||
constructor(private configService: ConfigService) {
|
||||
// Create the PostgreSQL client
|
||||
const connectionString = this.getDatabaseConnectionString();
|
||||
this.pool = new Pool({ connectionString });
|
||||
// Recreate drizzle with initialized pool
|
||||
this.db = drizzle(this.pool, { schema });
|
||||
|
||||
// Recreate drizzle with initialized pool
|
||||
this.db = drizzle(this.pool, { schema });
|
||||
}
|
||||
|
||||
async onModuleInit() {
|
||||
@@ -59,7 +61,9 @@ export class DatabaseService implements OnModuleInit, OnModuleDestroy {
|
||||
|
||||
// Get the database connection string from environment variables
|
||||
private getDatabaseConnectionString(): string {
|
||||
this.logger.debug('Getting database connection string from environment variables');
|
||||
this.logger.debug(
|
||||
"Getting database connection string from environment variables",
|
||||
);
|
||||
|
||||
const password = this.configService.get<string>("POSTGRES_PASSWORD");
|
||||
const username = this.configService.get<string>("POSTGRES_USER");
|
||||
@@ -80,7 +84,9 @@ export class DatabaseService implements OnModuleInit, OnModuleDestroy {
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
|
||||
this.logger.debug(`Database connection configured for ${username}@${host}:${port}/${database}`);
|
||||
this.logger.debug(
|
||||
`Database connection configured for ${username}@${host}:${port}/${database}`,
|
||||
);
|
||||
return `postgres://${username}:${password}@${host}:${port}/${database}`;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user