mirror of
https://github.com/Redume/Kekkai.git
synced 2025-02-23 04:33:11 +03:00
Теперь при запуске одного из JS сервисов, будет создаваться таблицы, если их нет
This commit is contained in:
parent
9443efae46
commit
a6c2dc7b06
3 changed files with 18 additions and 0 deletions
14
shared/database/src/create_table.js
Normal file
14
shared/database/src/create_table.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
const fs = require('fs');
|
||||
const pool = require('./postgresql.js');
|
||||
|
||||
async function create_table() {
|
||||
const schema = fs.readFileSync('../shared/database/data/schema.sql', 'utf8');
|
||||
|
||||
for (let i = 0; i < schema.split(';').length; i++) {
|
||||
try {
|
||||
await pool.query(schema.split(';')[i]);
|
||||
} catch (err) { continue }
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = create_table;
|
Loading…
Add table
Reference in a new issue