-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitdb.ts
36 lines (32 loc) · 810 Bytes
/
initdb.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { Pool } from "postgres";
const db = Deno.env.get("DB_URL")!;
const pool = new Pool(db, 3, true);
const conn = await pool.connect();
async function initDb() {
try {
await conn.queryObject`
CREATE TABLE testtololdon (
id SERIAL PRIMARY KEY,
inreplyto VARCHAR(100),
post_id VARCHAR(100) UNIQUE,
created_at TIMESTAMP,
handler VARCHAR(50),
display_name VARCHAR(256),
type VARCHAR(20),
status VARCHAR(10000),
url VARCHAR(1000),
ctext VARCHAR(10000),
remark VARCHAR(10),
media VARCHAR(1000)
)
`;
await conn.queryObject`
CREATE TABLE poeskoclokdon(
id SERIAL PRIMARY KEY,
post_id VARCHAR(100) UNIQUE)
`;
} finally {
conn.release();
}
}
initDb();