Skip to content

Commit 30f0745

Browse files
update seed.ts
1 parent 35ab6bf commit 30f0745

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

server/seed/seed.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
import 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
77
if (!process.env.USER_DB_URL) throw new Error('USER_DB_URL not found');
88
const connection = mysql.createConnection(process.env.USER_DB_URL);
99

1010
const 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

2529
loadData();
2630

27-
process.exit(0);
31+
process.exit(0);

0 commit comments

Comments
 (0)