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

Use db transactions in create and update operations #5403

Merged
merged 5 commits into from
Jan 27, 2024
Merged

Conversation

pxpm
Copy link
Contributor

@pxpm pxpm commented Dec 13, 2023

WHY

BEFORE - What was wrong? What was happening before this PR?

The queries to create/update an entry and it's relationships are not wrapped in a DB transaction, that means that any error during the operation would not invalidate the queries that were already commited, so you could have an entry in the database with only one of it's two relationships for example, or no relationships at all depending on when the error occurred.

AFTER - What is happening after this PR?

We discussed this during our meeting and got to the conclusion that wrapping those processes in a transaction is a key factor when data integrity must be assured. So if any query during those processes fail, the whole process is reverted and no queries are commited to the database.

HOW

How did you achieve that, in technical terms?

Using the DB::transaction provided by Laravel and making it configurable.

Is it a breaking change?

It can be seen as a BC yes, so it needed to be behind a feature flag that need to be enabled. We plan to make this the default in next version.

@pxpm
Copy link
Contributor Author

pxpm commented Jan 2, 2024

Hey @promatik this is ready for review we will launch it as in a minor version 6.6 in a few weeks or so, can you give it a go ?
Cheers

@pxpm
Copy link
Contributor Author

pxpm commented Jan 14, 2024

Did the changes @promatik thanks for the review 🙏

It's still false by default, and we will turn it true in v7.

Cheers

@promatik promatik merged commit beef0fc into main Jan 27, 2024
6 checks passed
@promatik promatik deleted the use-db-transactions branch January 27, 2024 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants