Skip to content

Commit 7cda0c3

Browse files
committed
Merge branch 'master' into releases/release-0.4.2
2 parents c797c97 + 35dc5bf commit 7cda0c3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def run
3636
dump.gsub!(/^COMMENT ON EXTENSION .*/, '')
3737

3838
# Remove useless, version-specific parts of comments
39-
dump.gsub!(/^-- (.*); Schema: ([\w_\.]+|-); Owner: -.*/, '-- \1')
39+
dump.gsub!(/^-- (.*); Schema: ([\w\.]+|-); Owner: -.*/, '-- \1')
4040

4141
# Remove useless comment lines
4242
dump.gsub!(/^--$/, '')
@@ -47,8 +47,8 @@ def run
4747
# This is a bit optimistic, but works as long as you don't have an id field thats not a sequence/uuid
4848
dump.gsub!(/^ id integer NOT NULL(,)?$/, ' id SERIAL PRIMARY KEY\1')
4949
dump.gsub!(/^ id bigint NOT NULL(,)?$/, ' id BIGSERIAL PRIMARY KEY\1')
50-
dump.gsub!(/^ id uuid DEFAULT ([\w_]+\.)?uuid_generate_v4\(\) NOT NULL(,)?$/, ' id uuid DEFAULT \1uuid_generate_v4() PRIMARY KEY\2')
51-
dump.gsub!(/^ id uuid DEFAULT ([\w_]+\.)?gen_random_uuid\(\) NOT NULL(,)?$/, ' id uuid DEFAULT \1gen_random_uuid() PRIMARY KEY\2')
50+
dump.gsub!(/^ id uuid DEFAULT ([\w]+\.)?uuid_generate_v4\(\) NOT NULL(,)?$/, ' id uuid DEFAULT \1uuid_generate_v4() PRIMARY KEY\2')
51+
dump.gsub!(/^ id uuid DEFAULT ([\w]+\.)?gen_random_uuid\(\) NOT NULL(,)?$/, ' id uuid DEFAULT \1gen_random_uuid() PRIMARY KEY\2')
5252
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;$/, '')
5353
dump.gsub!(/^ALTER SEQUENCE [\w\.]+_id_seq OWNED BY .*;$/, '')
5454
dump.gsub!(/^ALTER TABLE ONLY [\w\.]+ ALTER COLUMN id SET DEFAULT nextval\('[\w\.]+_id_seq'::regclass\);$/, '')
@@ -59,7 +59,7 @@ def run
5959
end
6060

6161
# Remove inherited tables
62-
inherited_tables_regexp = /-- Name: ([\w_\.]+); Type: TABLE\n\n[^;]+?INHERITS \([\w_\.]+\);/m
62+
inherited_tables_regexp = /-- Name: ([\w\.]+); Type: TABLE\n\n[^;]+?INHERITS \([\w\.]+\);/m
6363
inherited_tables = dump.scan(inherited_tables_regexp).map(&:first)
6464
dump.gsub!(inherited_tables_regexp, '')
6565
inherited_tables.each do |inherited_table|
@@ -76,7 +76,7 @@ def run
7676
partitioned_tables = []
7777

7878
# Postgres 12 pg_dump will output separate ATTACH PARTITION statements (even when run against an 11 or older server)
79-
partitioned_tables_regexp1 = /ALTER TABLE ONLY [\w_\.]+ ATTACH PARTITION ([\w_\.]+)/
79+
partitioned_tables_regexp1 = /ALTER TABLE ONLY [\w\.]+ ATTACH PARTITION ([\w\.]+)/
8080
partitioned_tables += dump.scan(partitioned_tables_regexp1).map(&:last)
8181

8282
# Earlier versions use an inline PARTITION OF

0 commit comments

Comments
 (0)