Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot rename collection #126

Closed
alkismavridis opened this issue Apr 21, 2021 · 2 comments
Closed

Cannot rename collection #126

alkismavridis opened this issue Apr 21, 2021 · 2 comments

Comments

@alkismavridis
Copy link

alkismavridis commented Apr 21, 2021

I try to execute a rename command:

<ext:runCommand>
      <ext:command><![CDATA[
        {
          renameCollection: "myDb.foo",
          to: "myDb.bar"
        }
      ]]></ext:command>
    </ext:runCommand>
  </changeSet>

But I get the following error: Command failed with error 13 (Unauthorized): 'renameCollection may only be run against the admin database.' The same command runs fine from studio3T.

Is there any step I am missing?

EDIT: The same error happens if I use adminCommand.

┆Issue is synchronized with this Jira Bug by Unito

@alexandru-slobodcicov
Copy link

Hi @alkismavridis it has to be used adminCommand see example :
https://github.com/liquibase/liquibase-mongodb/blob/main/src/test/resources/liquibase/ext/changelog.admin-command.test.xml
And specifically for renaming a collection:
https://github.com/liquibase/liquibase-mongodb/blob/main/src/test/java/liquibase/ext/mongodb/statement/AdminCommandStatementIT.java

Basically just change to :
<ext:adminCommand> <ext:command><![CDATA[ { renameCollection: "myDb.foo", to: "myDb.bar" } ]]></ext:command> </ext:adminCommand>

adminCommand does the switch do admin db and runs the command. Please ensure you are using latest extension as it was fixed in:
#111

Please note for adminCommand better to use placeholders for db name in order the scripts to be portable and could be applied to different DBs

@alexandru-slobodcicov
Copy link

Closing as a duplicate of #111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants