@@ -3,6 +3,7 @@ import { ConnectionPool } from '../ConnectionPool';
33import * as path from 'path' ;
44import * as fs from 'fs/promises' ;
55import Config from '../../config/index' ;
6+ import logger from '../../utils/logger' ;
67export class TablesService {
78 constructor ( private _connectionPool : ConnectionPool ) { }
89 @Catch ( {
@@ -16,7 +17,7 @@ export class TablesService {
1617 const sqlFilePath = Config . environment === 'production' ? productionPath : path . join ( __dirname , '..' , './sql/Tables.sql' ) ;
1718 const sql = await fs . readFile ( sqlFilePath , 'utf-8' ) ;
1819 await client . query ( sql ) ;
19- console . log ( 'Initial tables have been set up successfully.' ) ;
20+ logger . info ( 'Initial tables have been set up successfully.' ) ;
2021 }
2122 @Catch ( {
2223 category : 'Database' ,
@@ -28,13 +29,13 @@ export class TablesService {
2829 const result = await client . query ( `SELECT COUNT(*) FROM "User";` ) ;
2930 const userCount = parseInt ( result . rows [ 0 ] . count , 10 ) ;
3031 if ( userCount > 0 ) {
31- console . log ( 'The tables have already been seeded. Skipping seeding process.' ) ;
32+ logger . info ( 'The tables have already been seeded. Skipping seeding process.' ) ;
3233 return ; // Skip seeding if there's already data in the User table
3334 }
3435 const productionPath = path . join ( process . cwd ( ) , 'src' , 'database' , 'sql' , 'seed' , 'SeedDataTables.sql' ) ;
3536 const sqlFilePath = Config . environment === 'production' ? productionPath : path . join ( __dirname , '..' , './sql/seed/SeedDataTables.sql' ) ;
3637 const sql = await fs . readFile ( sqlFilePath , 'utf-8' ) ;
3738 await client . query ( sql ) ;
38- console . log ( 'All tables have been seeded successfully.' ) ;
39+ logger . info ( 'All tables have been seeded successfully.' ) ;
3940 }
4041}
0 commit comments