liquibase / node-liquibase

Node.js wrap for Liquibase
MIT License
32 stars 14 forks source link

Passing contexts to update command breaks #25

Open ramblingenzyme opened 3 years ago

ramblingenzyme commented 3 years ago

Liquibase expects the --context flag to be passed before the update action, but the wrapper generates the command string with the --context flag afterwards, unlike the example commands on the docs. https://docs.liquibase.com/concepts/advanced/contexts.html

# Expected
--contexts="staging" update
# Actual
update --contexts="staging"

I've "patched" this for my usecase by passing contexts as part of the Liquibase config


const config = {
    ...POSTGRESQL_DEFAULT_CONFIG,
    url,
    username,
    password,
    changeLogFile: "migrations/changelog.json", // Liquibase expects a relative path from the root directory, an absolute path breaks it
    contexts: MIGRATION_CONTEXTS || DEPLOY_ENV, // this isn't part of the normal LiquibaseConfig type but is needed here so the update command is generated correctly
};
tabuckner commented 3 years ago

@ramblingenzyme Thanks for reporting this :)

I'll get it taken care of. There was some misleading information in the Liquibase docs that led to this bug and a few others.

If you catch anything else like this, the only thing I can ask is that open an issue like you've done here! 🚀

ramblingenzyme commented 3 years ago

Thanks @tabuckner. I think I ran across some of those misleading Liquibase docs myself trying to track this down.

tabuckner commented 3 years ago

@ramblingenzyme going to cut a release today of your other issue and some minor fixes. The fix for this issue will not make that release, but I am actively working on this.

ramblingenzyme commented 3 years ago

Thanks @tabuckner.

tzifudzi commented 2 years ago

It appears this is still an issue. Is anyone working on this? @tabuckner Please guide me on the steps to contribute.

jocafi commented 1 year ago

I started a big project a few days ago using Liquibase and NodeJs, NestJs and so on. I am using the latest version of the tools. I could notice that the LiquibaseConfig model in TypeScript still does not have the parameter 'contexts' defined in the file liquibase-config.model.d.ts I used contexts before in the Java world. It works like a charm. But here, TypeScript is complaining:

Object literal may only specify known properties, and 'contexts' does not exist in type 'LiquibaseConfig'.

Does anyone know how can I pass the context in node-liquibase world ? Does it really work like in Java ?