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

Refactor DB setup Part 1 #105

Merged
merged 9 commits into from
Feb 12, 2024
Merged

Refactor DB setup Part 1 #105

merged 9 commits into from
Feb 12, 2024

Conversation

RichDom2185
Copy link
Member

Part of #14.

Part of #54.

Part of #81.

This design would remove coupling from the actual DB layer (as well as between models and its associations), as none of the SQL statements would actually be executed (but still allows to check for correctness of behaviour, especially when checking against potentially nullable/non-nullable values).

@RichDom2185 RichDom2185 self-assigned this Aug 18, 2023
@RichDom2185
Copy link
Member Author

After spending some time thinking about it, I figured this might be a good way to separate out the logic:

  • The general idea is that the actual DB transaction is contained within the model itself as a private method, thus controllers cannot mistakenly call it directly
  • The model will then expose a function that controllers can call to update the DB.

This design would also mean it would make it easier to make operations that involve multiple models atomic, simply by calling the individual structs' methods. An example of this atomicity issue was introduced in #102, where the usergroups data are dependent on the users themselves having been created prior to the operation. We can simply expose an create/update function from the UserGroups model that calls the methods from the individual structs (since they belong to the same package).

@RichDom2185 RichDom2185 requested a review from sayomaki January 23, 2024 12:18
Copy link

github-actions bot commented Jan 23, 2024

Coverage Status

coverage: 49.653% (-0.08%) from 49.731%
when pulling b74bbfc on refactor-db-1
into ec14721 on main.

@RichDom2185 RichDom2185 marked this pull request as ready for review February 12, 2024 13:57
@RichDom2185 RichDom2185 merged commit a603c40 into main Feb 12, 2024
4 checks passed
@RichDom2185 RichDom2185 deleted the refactor-db-1 branch February 12, 2024 13:58
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.

1 participant