File tree Expand file tree Collapse file tree 1 file changed +21
-17
lines changed
Expand file tree Collapse file tree 1 file changed +21
-17
lines changed Original file line number Diff line number Diff line change 11import mysql from 'mysql2' ;
2- import dotenv from 'dotenv'
3- dotenv . config ( )
4- import log from '../logger/index'
2+ import dotenv from 'dotenv' ;
3+ dotenv . config ( ) ;
4+ import log from '../logger/index' ;
55
66// Connect to SQL db and create users table
77if ( ! process . env . USER_DB_URL ) throw new Error ( 'USER_DB_URL not found' ) ;
88const connection = mysql . createConnection ( process . env . USER_DB_URL ) ;
99
1010const loadData = ( ) => {
11- const createUserTable = `
12- CREATE TABLE users (
13- id INT NOT NULL AUTO_INCREMENT,
14- PRIMARY KEY (id),
15- full_name VARCHAR(240),
16- sub VARCHAR(40),
17- email VARCHAR(240),
18- picture VARCHAR(240),
19- pg_schema TEXT
20- )` ;
21- try { connection . query ( createUserTable ) }
22- catch ( err ) { log . info ( err ) }
23- }
11+ const createUserTable = `CREATE TABLE
12+ 'users' (
13+ 'id' int NOT NULL AUTO_INCREMENT,
14+ 'full_name' varchar(240) NOT NULL,
15+ 'sub' varchar(40) DEFAULT NULL,
16+ 'email' varchar(240) NOT NULL,
17+ 'picture' varchar(240) DEFAULT NULL,
18+ 'pg_schema' text,
19+ 'password' varchar(240) NOT NULL,
20+ PRIMARY KEY ('id')
21+ ) ENGINE = InnoDB AUTO_INCREMENT = 40 DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci` ;
22+ try {
23+ connection . query ( createUserTable ) ;
24+ } catch ( err ) {
25+ log . info ( err ) ;
26+ }
27+ } ;
2428
2529loadData ( ) ;
2630
27- process . exit ( 0 ) ;
31+ process . exit ( 0 ) ;
You can’t perform that action at this time.
0 commit comments