activerecord-clean-db-structure 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +11 -11
- data/lib/activerecord-clean-db-structure/clean_dump.rb +9 -9
- data/lib/activerecord-clean-db-structure/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d36c390340cb86023df909cb5566610d47881767c746a118307f64c697e1153d
|
4
|
+
data.tar.gz: bc70ca9657712e25e5b925cc4184142831a83ffd36e103df6043c3713168005e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffa80995355e8d0e5404ea8f51eb82646e3b41a6c9ab95bd29db194a5fbbcdedce3e71c9f1da67f9ab8f6ca8b32ee336dc701e9f6a732e63b3c86e2a885ec8a7
|
7
|
+
data.tar.gz: b810eecc4cae33f4a1c0785188282264e0ad43a6975b28bf0bde9a3d1594e624f78f327ec343b9e679debe726d72856b323aef4a3004fb448e5683889d4f512b
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
activerecord-clean-db-structure (0.2.
|
4
|
+
activerecord-clean-db-structure (0.2.6)
|
5
5
|
activerecord (>= 4.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activemodel (5.1.
|
11
|
-
activesupport (= 5.1.
|
12
|
-
activerecord (5.1.
|
13
|
-
activemodel (= 5.1.
|
14
|
-
activesupport (= 5.1.
|
10
|
+
activemodel (5.1.5)
|
11
|
+
activesupport (= 5.1.5)
|
12
|
+
activerecord (5.1.5)
|
13
|
+
activemodel (= 5.1.5)
|
14
|
+
activesupport (= 5.1.5)
|
15
15
|
arel (~> 8.0)
|
16
|
-
activesupport (5.1.
|
16
|
+
activesupport (5.1.5)
|
17
17
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
18
18
|
i18n (~> 0.7)
|
19
19
|
minitest (~> 5.1)
|
20
20
|
tzinfo (~> 1.1)
|
21
21
|
arel (8.0.0)
|
22
22
|
concurrent-ruby (1.0.5)
|
23
|
-
i18n (0.9.
|
23
|
+
i18n (0.9.5)
|
24
24
|
concurrent-ruby (~> 1.0)
|
25
|
-
minitest (5.
|
25
|
+
minitest (5.11.3)
|
26
26
|
rake (0.9.6)
|
27
27
|
thread_safe (0.3.6)
|
28
|
-
tzinfo (1.2.
|
28
|
+
tzinfo (1.2.5)
|
29
29
|
thread_safe (~> 0.1)
|
30
30
|
|
31
31
|
PLATFORMS
|
@@ -36,4 +36,4 @@ DEPENDENCIES
|
|
36
36
|
rake (~> 0)
|
37
37
|
|
38
38
|
BUNDLED WITH
|
39
|
-
1.16.
|
39
|
+
1.16.1
|
@@ -38,24 +38,24 @@ module ActiveRecordCleanDbStructure
|
|
38
38
|
# This is a bit optimistic, but works as long as you don't have an id field thats not a sequence/uuid
|
39
39
|
dump.gsub!(/^ id integer NOT NULL(,)?$/, ' id SERIAL PRIMARY KEY\1')
|
40
40
|
dump.gsub!(/^ id bigint NOT NULL(,)?$/, ' id BIGSERIAL PRIMARY KEY\1')
|
41
|
-
dump.gsub!(/^ id uuid DEFAULT uuid_generate_v4\(\) NOT NULL(,)?$/, ' id uuid DEFAULT
|
42
|
-
dump.gsub!(/^ id uuid DEFAULT gen_random_uuid\(\) NOT NULL(,)?$/, ' id uuid DEFAULT
|
43
|
-
dump.gsub!(/^CREATE SEQUENCE \w+_id_seq\s+(AS integer\s+)?START WITH 1\s+INCREMENT BY 1\s+NO MINVALUE\s+NO MAXVALUE\s+CACHE 1;$/, '')
|
44
|
-
dump.gsub!(/^ALTER SEQUENCE \w+_id_seq OWNED BY .*;$/, '')
|
45
|
-
dump.gsub!(/^ALTER TABLE ONLY \w+ ALTER COLUMN id SET DEFAULT nextval\('\w+_id_seq'::regclass\);$/, '')
|
46
|
-
dump.gsub!(/^ALTER TABLE ONLY \w+\s+ADD CONSTRAINT \w+_pkey PRIMARY KEY \(id\);$/, '')
|
41
|
+
dump.gsub!(/^ id uuid DEFAULT (public\.)?uuid_generate_v4\(\) NOT NULL(,)?$/, ' id uuid DEFAULT \1uuid_generate_v4() PRIMARY KEY\2')
|
42
|
+
dump.gsub!(/^ id uuid DEFAULT (public\.)?gen_random_uuid\(\) NOT NULL(,)?$/, ' id uuid DEFAULT \1gen_random_uuid() PRIMARY KEY\2')
|
43
|
+
dump.gsub!(/^CREATE SEQUENCE [\w\.]+_id_seq\s+(AS integer\s+)?START WITH 1\s+INCREMENT BY 1\s+NO MINVALUE\s+NO MAXVALUE\s+CACHE 1;$/, '')
|
44
|
+
dump.gsub!(/^ALTER SEQUENCE [\w\.]+_id_seq OWNED BY .*;$/, '')
|
45
|
+
dump.gsub!(/^ALTER TABLE ONLY [\w\.]+ ALTER COLUMN id SET DEFAULT nextval\('[\w\.]+_id_seq'::regclass\);$/, '')
|
46
|
+
dump.gsub!(/^ALTER TABLE ONLY [\w\.]+\s+ADD CONSTRAINT [\w\.]+_pkey PRIMARY KEY \(id\);$/, '')
|
47
47
|
dump.gsub!(/^-- Name: (\w+\s+)?id; Type: DEFAULT$/, '')
|
48
48
|
dump.gsub!(/^-- .*_id_seq; Type: SEQUENCE.*/, '')
|
49
49
|
dump.gsub!(/^-- Name: (\w+\s+)?\w+_pkey; Type: CONSTRAINT$/, '')
|
50
50
|
|
51
51
|
# Remove inherited tables
|
52
|
-
inherited_tables_regexp = /-- Name: ([\w_]+); Type: TABLE\n\n[^;]+?INHERITS \([\w_]+\);/m
|
52
|
+
inherited_tables_regexp = /-- Name: ([\w_\.]+); Type: TABLE\n\n[^;]+?INHERITS \([\w_\.]+\);/m
|
53
53
|
inherited_tables = dump.scan(inherited_tables_regexp).map(&:first)
|
54
54
|
dump.gsub!(inherited_tables_regexp, '')
|
55
55
|
inherited_tables.each do |inherited_table|
|
56
|
-
dump.gsub!(/ALTER TABLE ONLY
|
56
|
+
dump.gsub!(/ALTER TABLE ONLY (public\.)?#{inherited_table}[^;]+;/, '')
|
57
57
|
|
58
|
-
index_regexp = /CREATE INDEX ([\w_]+) ON
|
58
|
+
index_regexp = /CREATE INDEX ([\w_]+) ON (public\.)?#{inherited_table}[^;]+;/m
|
59
59
|
dump.scan(index_regexp).map(&:first).each do |inherited_table_index|
|
60
60
|
dump.gsub!("-- Name: #{inherited_table_index}; Type: INDEX", '')
|
61
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-clean-db-structure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Fittl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.6
|
80
|
+
rubygems_version: 2.7.6
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: Automatic cleanup for the Rails db/structure.sql file (ActiveRecord/PostgreSQL)
|