From 5567fb494bc57332d5ec7d0fed60c3a36f10d962 Mon Sep 17 00:00:00 2001 From: Serhii Bodnaruk Date: Fri, 24 Jul 2026 20:04:36 +0300 Subject: [PATCH 1/2] Sort triggers, indexes, and check constraints for deterministic output Ensures annotations don't produce spurious diffs due to non-deterministic ordering of triggers, indexes, and check constraints from the database. --- lib/annotato/check_constraint_formatter.rb | 2 +- lib/annotato/index_formatter.rb | 2 +- lib/annotato/trigger_formatter.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/annotato/check_constraint_formatter.rb b/lib/annotato/check_constraint_formatter.rb index 2dc680e..0442cd7 100644 --- a/lib/annotato/check_constraint_formatter.rb +++ b/lib/annotato/check_constraint_formatter.rb @@ -5,7 +5,7 @@ class CheckConstraintFormatter extend WrapHelper def self.format(conn, table_name) - conn.check_constraints(table_name).map do |chk| + conn.check_constraints(table_name).sort_by(&:name).map do |chk| expr_clause = "" if chk.expression expr_clause = "\n" + wrap_sql(chk.expression, first_prefix: "# (", cont_prefix: "# ") diff --git a/lib/annotato/index_formatter.rb b/lib/annotato/index_formatter.rb index a307674..8fe99fb 100644 --- a/lib/annotato/index_formatter.rb +++ b/lib/annotato/index_formatter.rb @@ -5,7 +5,7 @@ class IndexFormatter extend WrapHelper def self.format(conn, table_name) - conn.indexes(table_name).map do |idx| + conn.indexes(table_name).sort_by(&:name).map do |idx| cols_list = Array(idx.columns).join(',') unique_clause = idx.unique ? " unique" : "" diff --git a/lib/annotato/trigger_formatter.rb b/lib/annotato/trigger_formatter.rb index 8b30c88..073a3be 100644 --- a/lib/annotato/trigger_formatter.rb +++ b/lib/annotato/trigger_formatter.rb @@ -24,7 +24,7 @@ def self.format(conn, table_name) return [] end - rows.map { |r| "# #{r['name']}" } + rows.map { |r| "# #{r['name']}" }.sort end end end From 057410b9e83e9484f237f248eb1976df335baa45 Mon Sep 17 00:00:00 2001 From: Serhii Bodnaruk Date: Fri, 24 Jul 2026 20:05:14 +0300 Subject: [PATCH 2/2] Bump version to 0.2.5 --- Gemfile.lock | 2 +- lib/annotato/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7f294a8..08dd1fc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - annotato (0.2.4) + annotato (0.2.5) rails (>= 6.0) GEM diff --git a/lib/annotato/version.rb b/lib/annotato/version.rb index f39ea3d..5212659 100644 --- a/lib/annotato/version.rb +++ b/lib/annotato/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Annotato - VERSION = "0.2.4" + VERSION = "0.2.5" end