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

Feature/delete cascade #503

Merged
merged 4 commits into from
Apr 16, 2024

Conversation

daschwanden
Copy link
Contributor

This PR proposes to introduce ON DELETE CASCADE referential actions on the auxiliary tables to enable database pruning.

See the new DB-PRUNINIG.md file with a description on how the proposed database pruning could be achieved leveraging the delete cascade relations.

DB-PRUNING.md Outdated
@@ -60,11 +60,11 @@ mysql> show tables;

Conveniently the auxiliary tables contain [ON DELETE CASCADE referential actions](https://dev.mysql.com/doc/refman/8.3/en/create-table-foreign-keys.html#foreign-key-referential-actions) on the respective [FOREIGN KEYS](https://dev.mysql.com/doc/refman/8.3/en/create-table-foreign-keys.html).

Therefore, we can focus on pruning rows from the three 'main' tables (```clients```,```messages``` and ```broadcasts```) to wip our Fleetspeak database back in shape. MySQL will ensure that the related tables and their entries will get cleared up accordingly.
Therefore, we can focus on pruning rows from the three 'main' tables (```clients```,```messages``` and ```broadcasts```) to wip our Fleetspeak database back into shape. MySQL will ensure that the related tables and their entries will get cleaned up accordingly.
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is also a typo in "wip" (but maybe it would be better to just use a different word ;-))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch. Thanks heaps.
Will update accordingly.

@@ -87,11 +87,11 @@ mysql> DESCRIBE clients;

### 3.2. Pruning clients

In the example ```DELETE``` command below we delete all the rows that have been created 148h (7 days) ago or older. Feel free to adjust the time according to your needs.
With the example ```DELETE``` command below we delete all the rows that have been created 168h (7 days) ago or older. Feel free to adjust the time according to your needs.
Copy link
Collaborator

Choose a reason for hiding this comment

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

good catch with the number! o_O

@gnoack gnoack self-assigned this Apr 11, 2024
@gnoack
Copy link
Collaborator

gnoack commented Apr 11, 2024

This seems OK to me, although I am not a MySQL expert, admittedly. If there are points where you are unsure, I'd suggest looping in @torsm ; otherwise we can also go ahead with it

@copybara-service copybara-service bot merged commit 8366b66 into google:master Apr 16, 2024
10 checks passed
@daschwanden daschwanden deleted the feature/delete-cascade branch April 16, 2024 13:12
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.

2 participants