Skip to content

Commit ea78555

Browse files
author
Carlos
authored
Merge pull request #68 from tomasc/fx-functions-at-beginning-of-schema
Update Fx support
2 parents cb1fe3d + b3c5bf3 commit ea78555

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

lib/torque/postgresql/adapter/schema_dumper.rb

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@ def schema_type(column)
2020
private
2121

2222
def tables(stream) # :nodoc:
23+
around_tables(stream) { dump_tables(stream) }
24+
end
25+
26+
def around_tables(stream)
27+
functions(stream) if fx_functions_position == :beginning
28+
29+
yield
30+
31+
functions(stream) if fx_functions_position == :end
32+
triggers(stream) if defined?(::Fx::SchemaDumper::Trigger)
33+
end
34+
35+
def dump_tables(stream)
2336
inherited_tables = @connection.inherited_tables
2437
sorted_tables = @connection.tables.sort - @connection.views
2538

@@ -55,13 +68,11 @@ def tables(stream) # :nodoc:
5568
foreign_keys(tbl, stream) unless ignored?(tbl)
5669
end
5770
end
71+
end
5872

59-
# Scenic integration
60-
views(stream) if defined?(::Scenic)
61-
62-
# FX integration
63-
functions(stream) if defined?(::Fx::SchemaDumper::Function)
64-
triggers(stream) if defined?(::Fx::SchemaDumper::Trigger)
73+
def fx_functions_position
74+
return unless defined?(::Fx::SchemaDumper::Function)
75+
Fx.configuration.dump_functions_at_beginning_of_schema ? :beginning : :end
6576
end
6677
end
6778

0 commit comments

Comments
 (0)