From 59e09bb3fcc0dd42063636e894f695849c035e7b Mon Sep 17 00:00:00 2001 From: Oleg Popkov Date: Fri, 7 Jul 2017 17:07:51 +0300 Subject: [PATCH] mask user mapping --- .gitignore | 1 + Gemfile.lock | 30 +++++++++---------- .../clean_dump.rb | 10 +++++++ .../version.rb | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 5fff1d9..b9250b7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ pkg +/.idea diff --git a/Gemfile.lock b/Gemfile.lock index aaf1f25..a7a0bc5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,29 +1,29 @@ PATH remote: . specs: - activerecord-clean-db-structure (0.2.0) + activerecord-clean-db-structure (0.2.1) activerecord (>= 4.2) GEM remote: https://rubygems.org/ specs: - activemodel (5.0.1) - activesupport (= 5.0.1) - activerecord (5.0.1) - activemodel (= 5.0.1) - activesupport (= 5.0.1) - arel (~> 7.0) - activesupport (5.0.1) + activemodel (5.1.2) + activesupport (= 5.1.2) + activerecord (5.1.2) + activemodel (= 5.1.2) + activesupport (= 5.1.2) + arel (~> 8.0) + activesupport (5.1.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) minitest (~> 5.1) tzinfo (~> 1.1) - arel (7.1.4) - concurrent-ruby (1.0.4) - i18n (0.8.0) - minitest (5.10.1) - thread_safe (0.3.5) - tzinfo (1.2.2) + arel (8.0.0) + concurrent-ruby (1.0.5) + i18n (0.8.4) + minitest (5.10.2) + thread_safe (0.3.6) + tzinfo (1.2.3) thread_safe (~> 0.1) PLATFORMS @@ -33,4 +33,4 @@ DEPENDENCIES activerecord-clean-db-structure! BUNDLED WITH - 1.12.5 + 1.15.1 diff --git a/lib/activerecord-clean-db-structure/clean_dump.rb b/lib/activerecord-clean-db-structure/clean_dump.rb index 3a17d8e..bdb1be8 100644 --- a/lib/activerecord-clean-db-structure/clean_dump.rb +++ b/lib/activerecord-clean-db-structure/clean_dump.rb @@ -27,6 +27,16 @@ def run # Remove useless comment lines dump.gsub!(/^--$/, '') + # Mask user mapping + dump.gsub!( + /^CREATE USER MAPPING FOR \w+ SERVER (\w+) .*;/m, + 'CREATE USER MAPPING FOR some_user SERVER \1;' + ) + dump.gsub!( + /^-- Name: USER MAPPING \w+ SERVER (\w+); Type: USER MAPPING/, + '-- Name: USER MAPPING some_user SERVER \1; Type: USER MAPPING' + ) + # Reduce noise for id fields by making them SERIAL instead of integer+sequence stuff # # This is a bit optimistic, but works as long as you don't have an id field thats not a sequence/uuid diff --git a/lib/activerecord-clean-db-structure/version.rb b/lib/activerecord-clean-db-structure/version.rb index 580d9e3..1b7f390 100644 --- a/lib/activerecord-clean-db-structure/version.rb +++ b/lib/activerecord-clean-db-structure/version.rb @@ -1,3 +1,3 @@ module ActiveRecordCleanDbStructure - VERSION = '0.2.0' + VERSION = '0.2.1' end