diff --git a/lib/code0/zero_track/database/schema_cleaner.rb b/lib/code0/zero_track/database/schema_cleaner.rb index 2601518..22faa8d 100644 --- a/lib/code0/zero_track/database/schema_cleaner.rb +++ b/lib/code0/zero_track/database/schema_cleaner.rb @@ -73,6 +73,9 @@ def remove_dynamic_partitions!(structure) # Remove ALTER INDEX ... ATTACH PARTITION .; structure.gsub!(/^ALTER INDEX \S+ ATTACH PARTITION #{schema}\.\S+;\n/, '') + + # Remove COMMENT ON TABLE . IS ''; + structure.gsub!(/^COMMENT ON TABLE #{schema}\.\S+ IS .*;\n/, '') end end end diff --git a/spec/code0/zero_track/database/schema_cleaner_spec.rb b/spec/code0/zero_track/database/schema_cleaner_spec.rb index ee5a94d..decca2e 100644 --- a/spec/code0/zero_track/database/schema_cleaner_spec.rb +++ b/spec/code0/zero_track/database/schema_cleaner_spec.rb @@ -120,6 +120,10 @@ ALTER TABLE ONLY users ADD CONSTRAINT users_pkey PRIMARY KEY (id); + COMMENT ON TABLE partitions_dynamic."p_audit_events_202606" IS '{"table":"p_audit_events","detached_at":"2026-10-17T15:32:48Z"}'; + + COMMENT ON TABLE "p_audit_events" IS 'partitioned table'; + CREATE INDEX index_p_audit_events_on_author_id ON ONLY p_audit_events USING btree (author_id); CREATE INDEX p_audit_events_202607_author_id_idx ON partitions_dynamic.p_audit_events_202607 USING btree (author_id); @@ -193,6 +197,14 @@ it 'preserves foreign keys on the parent table' do expect(clean).to include('fk_rails_9c5a4c4493 FOREIGN KEY (author_id) REFERENCES users(id)') end + + it 'removes comments from dynamic partitions' do + expect(clean).not_to include('COMMENT ON TABLE partitions_dynamic."p_audit_events_202606"') + end + + it 'preserves comment on the parent table' do + expect(clean).to include('COMMENT ON TABLE "p_audit_events"') + end end context 'with a custom dynamic partition schema name' do