@@ -3,29 +3,14 @@ import knex, { Knex } from 'knex';
33import log from '../../common/log' ;
44import { isDevelopment , isTest } from '../util/env' ;
55import { formatSQL } from './db_format' ;
6-
7- /*
8- psql -U postgres
9-
10- -- Main
11- CREATE DATABASE robot;
12- CREATE USER robot WITH ENCRYPTED PASSWORD 'robot';
13- GRANT ALL ON DATABASE robot TO robot;
14- ALTER DATABASE robot OWNER TO robot;
15- GRANT ALL PRIVILEGES ON DATABASE robot TO robot;
16- GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO robot;
17-
18- -- Test
19- CREATE DATABASE robot_test;
20- CREATE USER robot_test WITH ENCRYPTED PASSWORD 'robot_test';
21- GRANT ALL ON DATABASE robot_test TO robot_test;
22- ALTER DATABASE robot_test OWNER TO robot_test;
23- GRANT ALL PRIVILEGES ON DATABASE robot_test TO robot_test;
24- GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO robot_test;
25- */
6+ import { getDatabaseInitSQL } from './db_setup' ;
267
278const key = isTest ( ) ? 'robot_test' : 'robot' ;
289
10+ if ( isDevelopment ( ) || isTest ( ) ) {
11+ log . debug ( formatSQL ( getDatabaseInitSQL ( key ) ) ) ;
12+ }
13+
2914export type Transaction = Knex . Transaction ;
3015export type DB = knex . Knex < any , unknown [ ] > | Transaction ;
3116export type QueryBuilder = Knex . QueryBuilder ;
@@ -49,7 +34,8 @@ export const db = knex({
4934
5035db . on ( 'query' , async ( { sql } ) => {
5136 if ( isDevelopment ( ) ) {
52- log . info ( formatSQL ( sql ) ) ;
37+ log . debug ( formatSQL ( getDatabaseInitSQL ( key ) ) ) ;
38+ log . debug ( formatSQL ( sql ) ) ;
5339 }
5440} ) ;
5541
0 commit comments