migrate.ts 353 B

12345678910
  1. import { readFile } from 'node:fs/promises'
  2. import { fileURLToPath } from 'node:url'
  3. import { dirname, join } from 'node:path'
  4. import { pool } from './db.js'
  5. const here = dirname(fileURLToPath(import.meta.url))
  6. const sql = await readFile(join(here, 'schema.sql'), 'utf8')
  7. await pool.query(sql)
  8. console.log('Database schema is ready.')
  9. await pool.end()