logidze 0.12.0 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -5
  3. data/LICENSE.txt +1 -1
  4. data/README.md +263 -103
  5. data/lib/generators/logidze/fx_helper.rb +17 -0
  6. data/lib/generators/logidze/inject_sql.rb +18 -0
  7. data/lib/generators/logidze/install/USAGE +6 -1
  8. data/lib/generators/logidze/install/functions/logidze_compact_history.sql +38 -0
  9. data/lib/generators/logidze/install/functions/logidze_filter_keys.sql +27 -0
  10. data/lib/generators/logidze/install/functions/logidze_logger.sql +150 -0
  11. data/lib/generators/logidze/install/functions/logidze_snapshot.sql +24 -0
  12. data/lib/generators/logidze/install/functions/logidze_version.sql +20 -0
  13. data/lib/generators/logidze/install/install_generator.rb +58 -1
  14. data/lib/generators/logidze/install/templates/hstore.rb.erb +1 -1
  15. data/lib/generators/logidze/install/templates/migration.rb.erb +19 -232
  16. data/lib/generators/logidze/install/templates/migration_fx.rb.erb +41 -0
  17. data/lib/generators/logidze/model/model_generator.rb +49 -13
  18. data/lib/generators/logidze/model/templates/migration.rb.erb +57 -36
  19. data/lib/generators/logidze/model/triggers/logidze.sql +6 -0
  20. data/lib/logidze.rb +27 -14
  21. data/lib/logidze/history.rb +1 -10
  22. data/lib/logidze/ignore_log_data.rb +1 -4
  23. data/lib/logidze/model.rb +48 -35
  24. data/lib/logidze/version.rb +1 -1
  25. metadata +48 -73
  26. data/.gitattributes +0 -3
  27. data/.github/ISSUE_TEMPLATE.md +0 -20
  28. data/.github/PULL_REQUEST_TEMPLATE.md +0 -29
  29. data/.gitignore +0 -40
  30. data/.rubocop.yml +0 -55
  31. data/.travis.yml +0 -46
  32. data/Gemfile +0 -15
  33. data/Rakefile +0 -28
  34. data/assets/pg_log_data_chart.png +0 -0
  35. data/bench/performance/README.md +0 -109
  36. data/bench/performance/diff_bench.rb +0 -38
  37. data/bench/performance/insert_bench.rb +0 -22
  38. data/bench/performance/memory_profile.rb +0 -56
  39. data/bench/performance/setup.rb +0 -315
  40. data/bench/performance/update_bench.rb +0 -38
  41. data/bench/triggers/Makefile +0 -56
  42. data/bench/triggers/Readme.md +0 -58
  43. data/bench/triggers/bench.sql +0 -6
  44. data/bench/triggers/hstore_trigger_setup.sql +0 -38
  45. data/bench/triggers/jsonb_minus_2_setup.sql +0 -47
  46. data/bench/triggers/jsonb_minus_setup.sql +0 -49
  47. data/bench/triggers/keys2_trigger_setup.sql +0 -44
  48. data/bench/triggers/keys_trigger_setup.sql +0 -50
  49. data/bin/console +0 -8
  50. data/bin/setup +0 -9
  51. data/gemfiles/rails42.gemfile +0 -6
  52. data/gemfiles/rails5.gemfile +0 -6
  53. data/gemfiles/rails52.gemfile +0 -6
  54. data/gemfiles/rails6.gemfile +0 -6
  55. data/gemfiles/railsmaster.gemfile +0 -7
  56. data/lib/logidze/ignore_log_data/ignored_columns.rb +0 -46
  57. data/lib/logidze/migration.rb +0 -20
  58. data/logidze.gemspec +0 -41
@@ -1,7 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'arel', github: 'rails/arel'
4
- gem 'rails', github: 'rails/rails'
5
- gem 'rspec-rails', '>= 3.5'
6
-
7
- gemspec path: '..'
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Logidze
4
- module IgnoreLogData
5
- # Backports ignored_columns functionality to Rails < 5
6
- module IgnoredColumns
7
- module Base # :nodoc:
8
- attr_writer :ignored_columns
9
-
10
- def ignored_columns
11
- @ignored_columns ||= []
12
- end
13
- end
14
-
15
- module Relation # :nodoc:
16
- private
17
-
18
- def build_select(arel)
19
- if select_values.blank? && klass.ignored_columns.any? && ignores_log_data?
20
- arel.project(*arel_columns(klass.column_names - klass.ignored_columns))
21
- else
22
- super
23
- end
24
- end
25
- end
26
-
27
- module Table # :nodoc:
28
- def columns
29
- super.reject { |column| ignored_columns.include?(column.name) }
30
- end
31
-
32
- private
33
-
34
- def ignored_columns
35
- node.base_klass.ignored_columns
36
- end
37
- end
38
- end
39
- end
40
- end
41
-
42
- ActiveRecord::Base.extend(Logidze::IgnoreLogData::IgnoredColumns::Base)
43
- ActiveRecord::Relation.include(Logidze::IgnoreLogData::IgnoredColumns::Relation)
44
- ActiveRecord::Associations::JoinDependency::Aliases::Table.prepend(
45
- Logidze::IgnoreLogData::IgnoredColumns::Table
46
- )
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Logidze
4
- # Contains helpers for handling different PG versions
5
- module Migration
6
- # Checks whether pg function `current_setting` support `missing_ok` argument
7
- # (since 9.6)
8
- def current_setting_missing_supported?
9
- ActiveRecord::Base.connection.send(:postgresql_version) >= 90_600
10
- end
11
-
12
- def current_setting(name)
13
- if current_setting_missing_supported?
14
- "current_setting('#{name}', true)"
15
- else
16
- "current_setting('#{name}')"
17
- end
18
- end
19
- end
20
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("../lib", __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "logidze/version"
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = "logidze"
9
- spec.version = Logidze::VERSION
10
- spec.authors = ["palkan"]
11
- spec.email = ["dementiev.vm@gmail.com"]
12
-
13
- spec.summary = "PostgreSQL JSON-based auditing"
14
- spec.description = "PostgreSQL JSON-based auditing"
15
- spec.homepage = "http://github.com/palkan/logidze"
16
- spec.license = "MIT"
17
-
18
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
- spec.require_paths = ["lib"]
20
-
21
- spec.required_ruby_version = ">= 2.4.0"
22
-
23
- spec.metadata = {
24
- "bug_tracker_uri" => "http://github.com/palkan/logidze/issues",
25
- "changelog_uri" => "https://github.com/palkan/logidze/blob/master/CHANGELOG.md",
26
- "documentation_uri" => "http://github.com/palkan/logidze",
27
- "homepage_uri" => "http://github.com/palkan/logidze",
28
- "source_code_uri" => "http://github.com/palkan/logidze"
29
- }
30
-
31
- spec.add_dependency "rails", ">= 4.2"
32
-
33
- spec.add_development_dependency "ammeter", "~> 1.1.3"
34
- spec.add_development_dependency "bundler", ">= 1.10"
35
- spec.add_development_dependency "pg", ">= 0.18"
36
- spec.add_development_dependency "rake", ">= 10.0"
37
- spec.add_development_dependency "rspec-rails", ">= 3.4"
38
- spec.add_development_dependency "rubocop-md", "~> 0.2.0"
39
- spec.add_development_dependency "standard", "~> 0.1.2"
40
- spec.add_development_dependency "timecop", "~> 0.8"
41
- end