Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support renaming columns in migrations #2682

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

Merged
GromNaN merged 5 commits into mongodb:4.1 from hans-thomas:2391-rename-column
Nov 22, 2023

Conversation

@hans-thomas
Copy link
Contributor

@hans-thomas hans-thomas commented Nov 19, 2023
edited
Loading

Fix #2391
As mentioned in the linked issue, the renameColumn doesn't work. I just override that to fix the method.

Giacomo92 reacted with rocket emoji
@hans-thomas hans-thomas marked this pull request as ready for review November 19, 2023 13:50
Comment on lines +280 to +287
/** @inheritdoc */
public function renameColumn($from, $to)
{
$this->collection->updateMany([$from => ['$exists' => true]], ['$rename' => [$from => $to]]);

return $this;
}

Copy link
Contributor Author

@hans-thomas hans-thomas Nov 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, it finds the documents that have the $from column and then runs a query to rename their column to the $to.

alcaeus and GromNaN reacted with thumbs up emoji
@alcaeus alcaeus changed the title (削除) Fixing Rename column in migration (削除ここまで) (追記) Support renaming columns in migrations (追記ここまで) Nov 20, 2023
Copy link
Member

@GromNaN GromNaN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test should be more focused, otherwise LGTM.

@GromNaN GromNaN merged commit bcadf52 into mongodb:4.1 Nov 22, 2023
Copy link
Member

GromNaN commented Nov 22, 2023

Thank you @hans-thomas

hans-thomas reacted with heart emoji

Treggats pushed a commit to Treggats/laravel-mongodb that referenced this pull request Nov 22, 2023
@hans-thomas hans-thomas deleted the 2391-rename-column branch November 23, 2023 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@alcaeus alcaeus alcaeus approved these changes

@GromNaN GromNaN GromNaN approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Rename column in migration has no effect

AltStyle によって変換されたページ (->オリジナル) /