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

Fix crash destroying budgets with admins/valuators #4528

Merged
merged 1 commit into from
Jun 2, 2021

Conversation

javierm
Copy link
Member

@javierm javierm commented May 23, 2021

References

Background

We don't allow deleting a budget with associated investments. However, we allow deleting a budget with associated administrators and valuators. This results in a foreign key violation error:

PG::ForeignKeyViolation: ERROR:  update or delete on table "budgets" violates foreign key constraint "fk_rails_c847a52b1d" on table "budget_administrators"

Objectives

  • Make it possible to remove budgets without investments but with administrators

@javierm javierm added the Bug label May 23, 2021
@javierm javierm self-assigned this May 23, 2021
@javierm javierm added this to Reviewing in Consul Democracy via automation May 23, 2021
@javierm javierm force-pushed the budget_with_administrators branch from 8790371 to 2b9ca5a Compare May 23, 2021 22:06
@javierm javierm changed the title Fix crash destroying budget with administrators Fix crash destroying budgets with administrators May 23, 2021
@javierm javierm force-pushed the budget_with_administrators branch from 2b9ca5a to 3e6e3a9 Compare May 23, 2021 22:10
@javierm javierm changed the title Fix crash destroying budgets with administrators Fix crash destroying budgets with admins/valuators May 23, 2021
@javierm javierm force-pushed the budget_with_administrators branch 2 times, most recently from 930f8ca to e9be60b Compare May 29, 2021 12:35
@javierm javierm added the Admin label May 31, 2021
@taitus taitus self-assigned this Jun 2, 2021
We don't allow deleting a budget with associated investments. However,
we allow deleting a budget with associated administrators and valuators.
This results in a foreign key violation error:

PG::ForeignKeyViolation: ERROR:  update or delete on table "budgets"
violates foreign key constraint "fk_rails_c847a52b1d" on table
"budget_administrators"

Using the `dependent: :destroy` option when defining the relationship,
we remove the association records when removing the budget.

As a bonus, we reduce the number of Rubocop offenses regarding the
`Rails/HasManyOrHasOneDependent` rule. Only 72 to go! :)
@javierm javierm force-pushed the budget_with_administrators branch from e9be60b to a0942f6 Compare June 2, 2021 15:07
Consul Democracy automation moved this from Reviewing to Testing Jun 2, 2021
@javierm javierm merged commit c592d80 into master Jun 2, 2021
@javierm javierm deleted the budget_with_administrators branch June 2, 2021 15:59
Consul Democracy automation moved this from Testing to Release 1.3.1 Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants