Skip to content

Commit 8b05fab

Browse files
author
Clemens Kofler
committed
Fix: Clean up certain comments without names
I have lots of comments that look like this: -- Name: id; Type: DEFAULT -- Name: users_pkey; Type: CONSTRAINT Based on the previous regexes, it looks like the code assumed that at least with certain Postgres versions there's something before the name. But that's not the case for my version (9.5.4). Since I assume this is necessary for some Postgres versions, I've just made the offending part optional.
1 parent 92b9d71 commit 8b05fab

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ def run
3737
dump.gsub!(/^ALTER SEQUENCE \w+_id_seq OWNED BY .*;$/, '')
3838
dump.gsub!(/^ALTER TABLE ONLY \w+ ALTER COLUMN id SET DEFAULT nextval\('\w+_id_seq'::regclass\);$/, '')
3939
dump.gsub!(/^ALTER TABLE ONLY \w+\s+ADD CONSTRAINT \w+_pkey PRIMARY KEY \(id\);$/, '')
40-
dump.gsub!(/^-- Name: [\w_]+ id; Type: DEFAULT$/, '')
40+
dump.gsub!(/^-- Name: (\w+\s+)?id; Type: DEFAULT$/, '')
4141
dump.gsub!(/^-- .*_id_seq; Type: SEQUENCE.*/, '')
42-
dump.gsub!(/^-- Name: [\w_]+ \w+_pkey; Type: CONSTRAINT$/, '')
42+
dump.gsub!(/^-- Name: (\w+\s+)?\w+_pkey; Type: CONSTRAINT$/, '')
4343

4444
# Remove inherited tables
4545
inherited_tables_regexp = /-- Name: ([\w_]+); Type: TABLE\n\n[^;]+?INHERITS \([\w_]+\);/m

0 commit comments

Comments
 (0)