Skip to content

Drop RDMRecordQuota.user_id unique constraint #2037

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
merged 4 commits into from
Jun 27, 2025

Conversation

max-moser
Copy link
Contributor

@max-moser max-moser commented May 7, 2025

As discussed in Discord, this unique constraint prevents the creation of RDMRecordQuotas for several records per user and was likely just a copy-paste error from somewhere else.
In the Zenodo DB, this constraint was dropped already.

This PR chases that change.
ℹ️ for convenience reasons, i've also added a fix for the user quota not being respected to this PR (which took over as primary discussion point)

⚠️ since v13 has a bunch of new alembic recipes when compared to v12 already, backporting this fix to v12 would be nontrivial.
Given that v13 is scheduled to come out in just a few days (around 90), we'll just keep it a v13-only feature and add this to the list of known issues in v12.

Edit: Documentation update is here: inveniosoftware/docs-invenio-rdm#763

@max-moser max-moser changed the title Mm/record quota Drop RDMRecordQuota.user_id unique constraint May 7, 2025
@max-moser max-moser requested a review from anikachurilova May 8, 2025 10:02
@max-moser max-moser force-pushed the mm/record-quota branch 2 times, most recently from e1f382f to 729730f Compare May 8, 2025 14:23
Copy link
Member

@slint slint left a comment

Choose a reason for hiding this comment

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

LGTM and good to merge/release.

@utnapischtim in theory this would be a major bump. Installing this version wouldn't break anything though and it's just a matter of running the Alembic recipe to apply the fix. Thus I think it would be fine to just release a patch.

* this seems to have been a copy-paste error, or similar
* previously it was only possible to create an `RDMRecordQuota` for a
  single record per user due to this constraint
* previously, the quota setting logic only ran as part of
  `Record.create()` which is executed by the service before any service
  components are run
* since the ownership information is set in a dedicated service
  component, this caused the `get_files_quota()` function to never pick
  up the appropriate `RDMUserQuota` for new drafts
* so now we set the quota in a service component as well, to be run
  after the `AccessComponent`
@slint slint force-pushed the mm/record-quota branch from 02c3b02 to 8760db1 Compare June 25, 2025 11:54
@slint
Copy link
Member

slint commented Jun 25, 2025

I've rebased and removed the CHANGES.rst entries in the Version <next> section (since we'll add them when we cut a release from commit messages).

@utnapischtim utnapischtim merged commit 056f904 into inveniosoftware:master Jun 27, 2025
3 checks passed
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

Successfully merging this pull request may close these issues.

3 participants