Skip to content

Commit 657fe59

Browse files
committed
Add support for DBAGENT_IGNORED_FLUSH_FIELDS
1 parent 9dd0184 commit 657fe59

4 files changed

Lines changed: 15 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 3.9.7
2+
3+
* DBAGENT_IGNORED_FLUSH_FIELDS allows specifying fields to ignore when db:flush
4+
compares data to know whether a table has changed.
5+
16
## 3.9.6 - 2025-10-16
27

38
* Files dumped by db:flush are now sorted by primary key if possible.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ See the examples folder for details.
3636
* `DBAGENT_VIEWPOINT` Bmg viewpoint (class name) when using db:flush
3737
* `DBAGENT_MIGRATIONS_TABLE` The table containing the list of migrations (defaults to `schema_migrations`)
3838
* `DBAGENT_SUPERUSER_MIGRATIONS_TABLE` The table containing the list of superuser migrations (defaults to `superuser_migrations`)
39+
* `DBAGENT_IGNORED_FLUSH_FIELDS`. Fields ignored when db:flush compares data to dump/skip a table
3940

4041
## Available rake tasks
4142

lib/db_agent/seeder.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ def initialize(handler, database_suffix = nil)
99
end
1010
attr_reader :handler, :data_folder, :database_suffix
1111

12+
def ignored_flush_fields
13+
@ignored_flush_fields ||= begin
14+
ignored = ENV['DBAGENT_IGNORED_FLUSH_FIELDS'] || ''
15+
ignored.split(/\s*,\s*/).map(&:to_sym)
16+
end
17+
end
18+
1219
end # class Seeder
1320
end # module DbAgent
1421
require_relative 'seeder/actions'

lib/db_agent/seeder/relational.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ def flush_table(table, target_file, inherit_file)
109109
def same_data?(inherit_file, data)
110110
return false unless inherit_file.file?
111111

112-
r = Bmg.json(inherit_file)
113-
s = Bmg.in_memory(data)
112+
r = Bmg.json(inherit_file).allbut(ignored_flush_fields)
113+
s = Bmg.in_memory(data).allbut(ignored_flush_fields)
114114
same_set = (r.to_set == s.to_set)
115115
same_json = !same_set && (r.to_json == s.to_json)
116116
same_set || same_json

0 commit comments

Comments
 (0)