nestjs-liquibase
v0.0.5
Published
<div align="center"> <h2>liquibase-nestjs</h2> <p>A simple library for applying Liquibase in NestJS</p> </div>
Readme
English | 한국어
Installation
npm install nestjs-liquibaseQuick Start
1. Create Liquibase Changelog
The usage is described in the following structure. if you use a different structure, it should be applied as information in a different structure.
src/db/root.yaml
src/db/changelog/*.sqlSee /examples for more information.
2. Import LiquibaseModule
@Module({
imports: [
// ...
LiquibaseModule.regsiter({
allow: true,
config: {
...
}
})
],
})
export class AppModule {}- The
LiquibaseModule.register()function requires a parameter of TypeLiquibaseDynamicConfig. configis type of LiquibaseConfig based on liquibase library.
LiquibaseDynamicConfig Example
LiquibaseModule.register({
allow: true,
config: {
searchPath: "dist/db",
changeLogFile: "root.yaml",
url: "jdbc:postgresql://localhost:5432/postgres",
username: "postgres",
password: "mypassword",
}
})- You can also add it using
LiquibaseModule.registerAsync()
3. Edit nest-cli.json
When server build, edit nest-cli.json so that the Liquibase related files are can be copied to the build result.
"compilerOptions": {
"assets" : [
{
"include" : "db/root.yaml",
"outDir" : "dist"
},
{
"include": "db/changelog/*",
"outDir": "dist"
}
],
}When you build server, It will be copied to the build result as follows.
dist
ㄴ db
ㄴ root.yaml
ㄴ changelog
ㄴ create_member.sql 4. Run server
npm run startConsole Output
Note
- Currently, LiquibaseModule run
updatecommand of Liquibase
