I am using liquibase and mongo to execute a rename-migration like that:
<ext:runCommand>
<ext:command><![CDATA[
{
renameCollection: "XXX.foo",
to: "XXX.bar"
}
]]></ext:command>
</ext:runCommand>
The renaming happens within the bounds of the existing DB, so cross-db migrations are not relevant to my usecase. My problem is that I do now know XXX in advance. My liquibase migration is intended to run in multiple environmets and each one uses its unique version of XXX.
Also, liquibase limits me to runCommand/adminCommand semantics, and the spec for them clearly says that I should provide full namespaces for that, which I cannot have.
Of course I could create multiple liquibase change sets, one for each environment, and hardcode the proper namespace for each one. But I would like to avoid that option since it will does not scale very well.
Is there any way to rename a mongo collection (using runCommand/adminCommand semantics), in a namespace agnostic way?
Enter the database name as a parameter at the time of executing liquibase update and then use liquibase changelog property substitution in the changeset with the specified parameter. Should solve the problem.
Adding the way Alkis has achieved it as mentioned in comments :