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

Columns filtering #13

Closed
palkan opened this issue Nov 15, 2016 · 2 comments · Fixed by #16
Closed

Columns filtering #13

palkan opened this issue Nov 15, 2016 · 2 comments · Fixed by #16
Labels
CultOfMartians Task from http://cultofmartians.com enhancement

Comments

@palkan
Copy link
Owner

palkan commented Nov 15, 2016

What

We need a way to restrict versioning to a subset of columns.
These can be done in 2 ways: through whitelisting and blacklisting.

Why

To reduce the size of the log data.

How

Extend logidze_logger function (and related functions) to support 2 more arguments, except and only. Then CREATE TRIGGER migration looks like:

execute <<-SQL
  CREATE TRIGGER logidze_on_users
  BEFORE UPDATE OR INSERT ON users FOR EACH ROW
  WHEN (current_setting('logidze.disabled') <> 'on')
  EXECUTE PROCEDURE logidze_logger(null, null, '{name, role, email, phone}');
SQL

Where the first argument is a limit (as it is now), the second argument is a blacklist of columns, and the third argument is a whitelist of columns.

We should be able to specify these parameters through generator script:

rails generate logidze:model Post --only="title,user_id,tags"

rails generate logidze:model Post --except="created_at,updated_at"

We also need a way to upgrade existing triggers (maybe through the --upgrade flag).

@palkan palkan added enhancement CultOfMartians Task from http://cultofmartians.com labels Nov 15, 2016
@smaximov
Copy link
Contributor

smaximov commented Nov 18, 2016

Are --only and --except options mutually exclusive? If they are, wouldn't it be more convenient to have logidze_logger take a list of columns as the second argument and a boolean flag indicating the type of the filter (i.e., blacklist or whitelist)?

@palkan
Copy link
Owner Author

palkan commented Nov 18, 2016

Yes, they are exclusive.
And "yes" again: then boolean flag make sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CultOfMartians Task from http://cultofmartians.com enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants