misc
db mirgrate
到线上之后,deply
npx prisma migrate deploy
npx prisma generate
然后重启pm2进程。
PostgreSQL 迁移一个表
导出:
pg_dump -t api_models --data-only --column-inserts > api_models_data.sql
导入(注意,使用 pgcli 会报错!):
psql -f api_models_data.sql
ESM 中使用 __dirname
__dirname 是旧式 CommonJS 的变量,在 ESM 模式中可以如下使用:
import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// You can now use __dirname as you normally would
console.log(__dirname);