使用 NodeJS 运行 Liquibase

Adi*_*iee 5 liquibase node.js

我刚刚开始使用 Liquibase 进行自动数据库迁移。我了解 Liquibase 的基础知识,并且能够使用命令提示符运行它。我也想自动化这个过程。我希望 Liquibase 在 NodeJS 项目启动时运行。有帮助吗?

abe*_*rob 5

有了node-liquibase,您就可以做到这一点了。

const liquibase = require('liquibase');

liquibase({
  changeLogFile: 'resources/liquibase/db.changelog.xml',
  url: 'jdbc:postgresql://localhost:5432/postgres',
  username: 'postgres',
  password: 'admin'
})
.run('<action>', '<action-params>')
.then(() => console.log('success'))
.catch((err) => console.log('fail', err));
Run Code Online (Sandbox Code Playgroud)