initial commit
This commit is contained in:
commit
46911314f2
16 changed files with 1733 additions and 0 deletions
22
src/db.ts
Normal file
22
src/db.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { Pool } from 'pg';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
export const pgPool = new Pool({
|
||||
host: process.env.POSTGRES_HOST,
|
||||
port: Number(process.env.POSTGRES_PORT || 5432),
|
||||
database: process.env.POSTGRES_DB,
|
||||
user: process.env.POSTGRES_USER,
|
||||
password: process.env.POSTGRES_PASSWORD,
|
||||
});
|
||||
|
||||
export async function initDb(): Promise<void> {
|
||||
await pgPool.query(`
|
||||
CREATE TABLE IF NOT EXISTS motd (
|
||||
id SERIAL PRIMARY KEY,
|
||||
message TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT NOW()
|
||||
)
|
||||
`);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue