Skip to content

Commit eddd996

Browse files
amik0Ermolaev Andrey
authored and
Ermolaev Andrey
committed
mask user mapping (#1)
1 parent 8500408 commit eddd996

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pkg
2+
/.idea

Gemfile.lock

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
PATH
22
remote: .
33
specs:
4-
activerecord-clean-db-structure (0.2.0)
4+
activerecord-clean-db-structure (0.2.1)
55
activerecord (>= 4.2)
66

77
GEM
88
remote: https://rubygems.org/
99
specs:
10-
activemodel (5.0.1)
11-
activesupport (= 5.0.1)
12-
activerecord (5.0.1)
13-
activemodel (= 5.0.1)
14-
activesupport (= 5.0.1)
15-
arel (~> 7.0)
16-
activesupport (5.0.1)
10+
activemodel (5.1.2)
11+
activesupport (= 5.1.2)
12+
activerecord (5.1.2)
13+
activemodel (= 5.1.2)
14+
activesupport (= 5.1.2)
15+
arel (~> 8.0)
16+
activesupport (5.1.2)
1717
concurrent-ruby (~> 1.0, >= 1.0.2)
1818
i18n (~> 0.7)
1919
minitest (~> 5.1)
2020
tzinfo (~> 1.1)
21-
arel (7.1.4)
22-
concurrent-ruby (1.0.4)
23-
i18n (0.8.0)
24-
minitest (5.10.1)
25-
thread_safe (0.3.5)
26-
tzinfo (1.2.2)
21+
arel (8.0.0)
22+
concurrent-ruby (1.0.5)
23+
i18n (0.8.4)
24+
minitest (5.10.2)
25+
thread_safe (0.3.6)
26+
tzinfo (1.2.3)
2727
thread_safe (~> 0.1)
2828

2929
PLATFORMS
@@ -33,4 +33,4 @@ DEPENDENCIES
3333
activerecord-clean-db-structure!
3434

3535
BUNDLED WITH
36-
1.12.5
36+
1.15.1

lib/activerecord-clean-db-structure/clean_dump.rb

+10
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ def run
2727
# Remove useless comment lines
2828
dump.gsub!(/^--$/, '')
2929

30+
# Mask user mapping
31+
dump.gsub!(
32+
/^CREATE USER MAPPING FOR \w+ SERVER (\w+) .*;/m,
33+
'CREATE USER MAPPING FOR some_user SERVER \1;'
34+
)
35+
dump.gsub!(
36+
/^-- Name: USER MAPPING \w+ SERVER (\w+); Type: USER MAPPING/,
37+
'-- Name: USER MAPPING some_user SERVER \1; Type: USER MAPPING'
38+
)
39+
3040
# Reduce noise for id fields by making them SERIAL instead of integer+sequence stuff
3141
#
3242
# This is a bit optimistic, but works as long as you don't have an id field thats not a sequence/uuid
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module ActiveRecordCleanDbStructure
2-
VERSION = '0.2.0'
2+
VERSION = '0.2.1'
33
end

0 commit comments

Comments
 (0)