记录 Sequelize 迁移 [英] Logging Sequelize Migrations

查看:40
本文介绍了记录 Sequelize 迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚开始使用 Sequelize 并尝试使迁移正常工作,并希望查看迁移实际针对数据库运行的 SQL.

Just getting started with Sequelize and trying to get migrations working and would like to see what SQL the migrations are actually running against the DB.

我发现了一个 github 评论,它建议了如何管理日志记录到调试模块,但我把选项"放在哪里.

I found a github comment which suggests how to pipe the logging to the debug module, but where do I put the "options".

options: {
  logging: debug('sequelize')
}

推荐答案

在配置连接数据库(文件 data_base.json)中启用 "logging":true.

Enable "logging":true in config conection data base (file data_base.json).

示例

{
    "username": "postgres",
    "password": "postgres",
    "database": "agencias",
    "host": "127.0.0.1",
    "dialect": "postgres",
    "timezone": "America/La_Paz",

    "migrationStorage": "sequelize",
    "migrationStorageTableName": "sequelize_migration",
    "logging":true,
    "pool": {
        "max": 15,
        "min": 0,
        "idle": 10000
    }
}

在项目中执行

sequelize db:migrate --migrations-path src/migrations --config data_base.json

这篇关于记录 Sequelize 迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆