laravel-auditing icon indicating copy to clipboard operation
laravel-auditing copied to clipboard

Can we make it possible to store tags in seperate table?

Open iwasherefirst2 opened this issue 3 years ago • 3 comments

| Bug? | no | New Feature? |yes | Framework | Laravel | Framework version | 8.12 | Package version | 12.0 | PHP version | ^8.0

Actual Behaviour

Tags are stored in tags column of Audit Model

Expected Behaviour

I would like to be able to store tags in a seperate table, because when multiple tags are inside "tags" column filtering using SQL becomes very slow since one cannot use indexing.

Possible Solutions

Instead of directly calling create on the implementation at https://github.com/owen-it/laravel-auditing/blob/5659c736f17aa75805b60c0d0a23783f3bf5c2a1/src/Drivers/Database.php#L19 one could use a UserCreate service that is called (just as we have the resolver services). In this service class, only the create method is called.

Thus the UserCreate service could be overwritten in the configs (just as the resolvers). People could then choose freely if they would like to store the tags in a different table inside their custom UserCreate service.

If you agree with this small change, I would like to create the MR.

iwasherefirst2 avatar Nov 01 '21 10:11 iwasherefirst2

It's a pretty good idea. I imagine it would make for a significant improvement when querying/filtering by tags on very large table.

MortenDHansen avatar Jan 27 '22 11:01 MortenDHansen

Is there any update on this matter? We have a sizable project, and the audit table contains millions of records. Therefore, searching using LIKE is an extremely time-consuming task.

idoomguy avatar Mar 23 '23 09:03 idoomguy

Is there any update on this matter? We have a sizable project, and the audit table contains millions of records. Therefore, searching using LIKE is an extremely time-consuming task.

Yes. It will happen. But I can't put a date on it yet

MortenDHansen avatar Mar 23 '23 10:03 MortenDHansen