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

Make the data migration's left join update compatible #17355

Conversation

danidoni
Copy link
Contributor

@danidoni danidoni commented Feb 7, 2025

Looks like writing it by hand needs a bit more sql statements to make it compatible with an update statement, so we let ActiveRecord craft it for us.

Fixes #17354

Looks like writing it by hand needs a bit more sql statements to make
it compatible with an update statement, so we let ActiveRecord craft
it for us.

Fixes openSUSE#17354
@github-actions github-actions bot added the Frontend Things related to the OBS RoR app label Feb 7, 2025
@@ -4,14 +4,17 @@ class NullifyTargetsOnBsRequestActions < ActiveRecord::Migration[7.0]
# rubocop:disable Rails/SkipsModelValidations
def up
BsRequestAction
.joins('LEFT JOIN projects ON bs_request_actions.target_project_id = projects.id WHERE bs_request_actions.target_project_id IS NOT NULL AND projects.id IS NULL')
.left_joins(:target_project_object)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of the table name, we need to use the association name: this one

@danidoni danidoni marked this pull request as ready for review February 7, 2025 13:19
@danidoni danidoni merged commit 42c4a08 into openSUSE:master Feb 7, 2025
22 checks passed
@danidoni danidoni deleted the make-the-nullify-data-migrations-left-join-update-compatible branch February 7, 2025 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frontend Things related to the OBS RoR app
Projects
None yet
2 participants