fx 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +2 -7
  3. data/CHANGELOG.md +124 -0
  4. data/CONTRIBUTING.md +3 -3
  5. data/Gemfile +12 -1
  6. data/README.md +2 -0
  7. data/bin/standardrb +27 -0
  8. data/fx.gemspec +10 -15
  9. data/lib/fx/adapters/postgres/connection.rb +12 -0
  10. data/lib/fx/adapters/postgres/functions.rb +3 -3
  11. data/lib/fx/adapters/postgres/triggers.rb +3 -3
  12. data/lib/fx/adapters/postgres.rb +6 -14
  13. data/lib/fx/command_recorder.rb +87 -6
  14. data/lib/fx/configuration.rb +0 -25
  15. data/lib/fx/definition.rb +16 -6
  16. data/lib/fx/function.rb +3 -3
  17. data/lib/fx/schema_dumper.rb +45 -5
  18. data/lib/fx/statements.rb +228 -6
  19. data/lib/fx/trigger.rb +3 -3
  20. data/lib/fx/version.rb +1 -1
  21. data/lib/fx.rb +30 -12
  22. data/lib/generators/fx/function/function_generator.rb +2 -2
  23. data/lib/generators/fx/trigger/trigger_generator.rb +1 -5
  24. data/spec/acceptance/user_manages_functions_spec.rb +4 -4
  25. data/spec/acceptance/user_manages_triggers_spec.rb +6 -6
  26. data/spec/acceptance_helper.rb +2 -2
  27. data/spec/dummy/config/application.rb +5 -1
  28. data/spec/features/functions/migrations_spec.rb +3 -3
  29. data/spec/features/functions/revert_spec.rb +3 -3
  30. data/spec/features/triggers/migrations_spec.rb +4 -4
  31. data/spec/features/triggers/revert_spec.rb +5 -5
  32. data/spec/fx/adapters/postgres/functions_spec.rb +26 -30
  33. data/spec/fx/adapters/postgres/triggers_spec.rb +34 -38
  34. data/spec/fx/adapters/postgres_spec.rb +107 -109
  35. data/spec/fx/command_recorder_spec.rb +27 -25
  36. data/spec/fx/configuration_spec.rb +20 -9
  37. data/spec/fx/definition_spec.rb +27 -35
  38. data/spec/fx/function_spec.rb +45 -48
  39. data/spec/fx/schema_dumper_spec.rb +123 -0
  40. data/spec/fx/statements_spec.rb +217 -0
  41. data/spec/fx/trigger_spec.rb +37 -40
  42. data/spec/fx_spec.rb +28 -0
  43. data/spec/generators/fx/function/function_generator_spec.rb +3 -3
  44. data/spec/generators/fx/trigger/trigger_generator_spec.rb +10 -10
  45. data/spec/spec_helper.rb +5 -0
  46. data/spec/support/definition_helpers.rb +2 -6
  47. data/spec/support/warning_helper.rb +5 -0
  48. metadata +21 -163
  49. data/lib/fx/command_recorder/arguments.rb +0 -43
  50. data/lib/fx/command_recorder/function.rb +0 -30
  51. data/lib/fx/command_recorder/trigger.rb +0 -30
  52. data/lib/fx/schema_dumper/function.rb +0 -38
  53. data/lib/fx/schema_dumper/trigger.rb +0 -29
  54. data/lib/fx/statements/function.rb +0 -113
  55. data/lib/fx/statements/trigger.rb +0 -144
  56. data/spec/fx/command_recorder/arguments_spec.rb +0 -41
  57. data/spec/fx/schema_dumper/function_spec.rb +0 -78
  58. data/spec/fx/schema_dumper/trigger_spec.rb +0 -40
  59. data/spec/fx/statements/function_spec.rb +0 -103
  60. data/spec/fx/statements/trigger_spec.rb +0 -132
data/spec/fx_spec.rb ADDED
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Fx do
4
+ it "has a version number" do
5
+ expect(Fx::VERSION).to be_present
6
+ end
7
+
8
+ it "loads fx into ActiveRecord" do
9
+ expect(ActiveRecord::Migration::CommandRecorder).to include(Fx::CommandRecorder)
10
+ expect(ActiveRecord::ConnectionAdapters::AbstractAdapter).to include(Fx::Statements)
11
+ expect(ActiveRecord::SchemaDumper).to include(Fx::SchemaDumper)
12
+ expect(Fx.load).to eq(true)
13
+ end
14
+
15
+ it "allows configuration" do
16
+ adapter = double("Fx Adapter")
17
+
18
+ Fx.configure do |config|
19
+ config.database = adapter
20
+ config.dump_functions_at_beginning_of_schema = true
21
+ end
22
+
23
+ expect(Fx.configuration.database).to eq(adapter)
24
+ expect(Fx.configuration.dump_functions_at_beginning_of_schema).to eq(true)
25
+
26
+ Fx.configuration = nil
27
+ end
28
+ end
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
  require "generators/fx/function/function_generator"
3
3
 
4
- describe Fx::Generators::FunctionGenerator, :generator do
4
+ RSpec.describe Fx::Generators::FunctionGenerator, :generator do
5
5
  it "creates a function definition file, and a migration" do
6
6
  migration = file("db/migrate/create_function_test.rb")
7
7
  function_definition = file("db/functions/test_v01.sql")
@@ -10,7 +10,7 @@ describe Fx::Generators::FunctionGenerator, :generator do
10
10
 
11
11
  expect(function_definition).to exist
12
12
  expect(migration).to be_a_migration
13
- expect(migration_file(migration)).to contain "CreateFunctionTest"
13
+ expect(migration_file(migration)).to contain("CreateFunctionTest")
14
14
  end
15
15
 
16
16
  context "when passed --no-migration" do
@@ -21,7 +21,7 @@ describe Fx::Generators::FunctionGenerator, :generator do
21
21
  run_generator ["test", "--no-migration"]
22
22
 
23
23
  expect(function_definition).to exist
24
- expect(migration_file(migration)).not_to exist
24
+ expect(Pathname.new(migration_file(migration))).not_to exist
25
25
  end
26
26
  end
27
27
 
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
  require "generators/fx/trigger/trigger_generator"
3
3
 
4
- describe Fx::Generators::TriggerGenerator, :generator do
4
+ RSpec.describe Fx::Generators::TriggerGenerator, :generator do
5
5
  it "creates a trigger definition file, and a migration" do
6
6
  migration = file("db/migrate/create_trigger_test.rb")
7
7
  trigger_definition = file("db/triggers/test_v01.sql")
@@ -10,8 +10,8 @@ describe Fx::Generators::TriggerGenerator, :generator do
10
10
 
11
11
  expect(trigger_definition).to exist
12
12
  expect(migration).to be_a_migration
13
- expect(migration_file(migration)).to contain "CreateTriggerTest"
14
- expect(migration_file(migration)).to contain "on: :some_table"
13
+ expect(migration_file(migration)).to contain("CreateTriggerTest")
14
+ expect(migration_file(migration)).to contain("on: :some_table")
15
15
  end
16
16
 
17
17
  context "when passed --no-migration" do
@@ -22,7 +22,7 @@ describe Fx::Generators::TriggerGenerator, :generator do
22
22
  run_generator ["test", {"table_name" => "some_table"}, "--no-migration"]
23
23
 
24
24
  expect(trigger_definition).to exist
25
- expect(migration_file(migration)).not_to exist
25
+ expect(Pathname.new(migration_file(migration))).not_to exist
26
26
  end
27
27
  end
28
28
 
@@ -34,14 +34,14 @@ describe Fx::Generators::TriggerGenerator, :generator do
34
34
 
35
35
  expect(trigger_definition).to exist
36
36
  expect(migration).to be_a_migration
37
- expect(migration_file(migration)).to contain "CreateTriggerTest"
38
- expect(migration_file(migration)).to contain "on: :some_table"
37
+ expect(migration_file(migration)).to contain("CreateTriggerTest")
38
+ expect(migration_file(migration)).to contain("on: :some_table")
39
39
  end
40
40
 
41
41
  it "requires `table_name` or `on` to be specified" do
42
- expect {
42
+ expect do
43
43
  run_generator ["test", "foo" => "some_table"]
44
- }.to raise_error ArgumentError
44
+ end.to raise_error(ArgumentError)
45
45
  end
46
46
 
47
47
  it "updates an existing trigger" do
@@ -53,7 +53,7 @@ describe Fx::Generators::TriggerGenerator, :generator do
53
53
 
54
54
  expect(trigger_definition).to exist
55
55
  expect(migration).to be_a_migration
56
- expect(migration_file(migration)).to contain "UpdateTriggerTestToVersion2"
57
- expect(migration_file(migration)).to contain "on: :some_table"
56
+ expect(migration_file(migration)).to contain("UpdateTriggerTestToVersion2")
57
+ expect(migration_file(migration)).to contain("on: :some_table")
58
58
  end
59
59
  end
data/spec/spec_helper.rb CHANGED
@@ -4,8 +4,13 @@ require "database_cleaner"
4
4
  require File.expand_path("../dummy/config/environment", __FILE__)
5
5
  Dir["spec/support/**/*.rb"].sort.each { |file| load file }
6
6
 
7
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
8
+ require "fx"
9
+
7
10
  RSpec.configure do |config|
8
11
  config.order = "random"
12
+ config.disable_monkey_patching!
13
+
9
14
  DatabaseCleaner.strategy = :transaction
10
15
 
11
16
  config.around(:each, db: true) do |example|
@@ -1,6 +1,6 @@
1
1
  module DefinitionHelpers
2
2
  def with_function_definition(name:, sql_definition:, version: 1, &block)
3
- definition = Fx::Definition.new(name: name, version: version)
3
+ definition = Fx::Definition.function(name: name, version: version)
4
4
 
5
5
  with_definition(
6
6
  definition: definition,
@@ -10,11 +10,7 @@ module DefinitionHelpers
10
10
  end
11
11
 
12
12
  def with_trigger_definition(name:, sql_definition:, version: 1, &block)
13
- definition = Fx::Definition.new(
14
- name: name,
15
- version: version,
16
- type: "trigger"
17
- )
13
+ definition = Fx::Definition.trigger(name: name, version: version)
18
14
 
19
15
  with_definition(
20
16
  definition: definition,
@@ -0,0 +1,5 @@
1
+ require "warning"
2
+
3
+ Warning.process do |_|
4
+ :raise
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Teo Ljungberg
@@ -10,177 +10,37 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 1980-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ammeter
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.1.3
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 1.1.3
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '1.5'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '1.5'
41
- - !ruby/object:Gem::Dependency
42
- name: database_cleaner
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: pg
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: pry
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: redcarpet
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rspec
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '3.3'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '3.3'
125
- - !ruby/object:Gem::Dependency
126
- name: standardrb
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: yard
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
13
  - !ruby/object:Gem::Dependency
154
14
  name: activerecord
155
15
  requirement: !ruby/object:Gem::Requirement
156
16
  requirements:
157
17
  - - ">="
158
18
  - !ruby/object:Gem::Version
159
- version: 6.0.0
19
+ version: '7.0'
160
20
  type: :runtime
161
21
  prerelease: false
162
22
  version_requirements: !ruby/object:Gem::Requirement
163
23
  requirements:
164
24
  - - ">="
165
25
  - !ruby/object:Gem::Version
166
- version: 6.0.0
26
+ version: '7.0'
167
27
  - !ruby/object:Gem::Dependency
168
28
  name: railties
169
29
  requirement: !ruby/object:Gem::Requirement
170
30
  requirements:
171
31
  - - ">="
172
32
  - !ruby/object:Gem::Version
173
- version: 6.0.0
33
+ version: '7.0'
174
34
  type: :runtime
175
35
  prerelease: false
176
36
  version_requirements: !ruby/object:Gem::Requirement
177
37
  requirements:
178
38
  - - ">="
179
39
  - !ruby/object:Gem::Version
180
- version: 6.0.0
181
- description: |2
182
- Adds methods to ActiveRecord::Migration to create and manage database functions
183
- and triggers in Rails
40
+ version: '7.0'
41
+ description: |
42
+ Adds methods to ActiveRecord::Migration to create and manage database functions
43
+ and triggers in Rails
184
44
  email:
185
45
  - teo@teoljungberg.com
186
46
  executables: []
@@ -192,6 +52,7 @@ files:
192
52
  - ".rspec"
193
53
  - ".standard.yml"
194
54
  - ".yardopts"
55
+ - CHANGELOG.md
195
56
  - CONTRIBUTING.md
196
57
  - Gemfile
197
58
  - LICENSE
@@ -201,6 +62,7 @@ files:
201
62
  - bin/rake
202
63
  - bin/rspec
203
64
  - bin/setup
65
+ - bin/standardrb
204
66
  - bin/yard
205
67
  - fx.gemspec
206
68
  - lib/fx.rb
@@ -209,19 +71,12 @@ files:
209
71
  - lib/fx/adapters/postgres/functions.rb
210
72
  - lib/fx/adapters/postgres/triggers.rb
211
73
  - lib/fx/command_recorder.rb
212
- - lib/fx/command_recorder/arguments.rb
213
- - lib/fx/command_recorder/function.rb
214
- - lib/fx/command_recorder/trigger.rb
215
74
  - lib/fx/configuration.rb
216
75
  - lib/fx/definition.rb
217
76
  - lib/fx/function.rb
218
77
  - lib/fx/railtie.rb
219
78
  - lib/fx/schema_dumper.rb
220
- - lib/fx/schema_dumper/function.rb
221
- - lib/fx/schema_dumper/trigger.rb
222
79
  - lib/fx/statements.rb
223
- - lib/fx/statements/function.rb
224
- - lib/fx/statements/trigger.rb
225
80
  - lib/fx/trigger.rb
226
81
  - lib/fx/version.rb
227
82
  - lib/generators.rb
@@ -254,26 +109,29 @@ files:
254
109
  - spec/fx/adapters/postgres/functions_spec.rb
255
110
  - spec/fx/adapters/postgres/triggers_spec.rb
256
111
  - spec/fx/adapters/postgres_spec.rb
257
- - spec/fx/command_recorder/arguments_spec.rb
258
112
  - spec/fx/command_recorder_spec.rb
259
113
  - spec/fx/configuration_spec.rb
260
114
  - spec/fx/definition_spec.rb
261
115
  - spec/fx/function_spec.rb
262
- - spec/fx/schema_dumper/function_spec.rb
263
- - spec/fx/schema_dumper/trigger_spec.rb
264
- - spec/fx/statements/function_spec.rb
265
- - spec/fx/statements/trigger_spec.rb
116
+ - spec/fx/schema_dumper_spec.rb
117
+ - spec/fx/statements_spec.rb
266
118
  - spec/fx/trigger_spec.rb
119
+ - spec/fx_spec.rb
267
120
  - spec/generators/fx/function/function_generator_spec.rb
268
121
  - spec/generators/fx/trigger/trigger_generator_spec.rb
269
122
  - spec/spec_helper.rb
270
123
  - spec/support/definition_helpers.rb
271
124
  - spec/support/generator_setup.rb
272
125
  - spec/support/migration_helpers.rb
126
+ - spec/support/warning_helper.rb
273
127
  homepage: https://github.com/teoljungberg/fx
274
128
  licenses:
275
129
  - MIT
276
- metadata: {}
130
+ metadata:
131
+ bug_tracker_uri: https://github.com/teoljungberg/fx/issues
132
+ changelog_uri: https://github.com/teoljungberg/fx/blob/v0.9.0/CHANGELOG.md
133
+ homepage_uri: https://github.com/teoljungberg/fx
134
+ source_code_uri: https://github.com/teoljungberg/fx
277
135
  post_install_message:
278
136
  rdoc_options: []
279
137
  require_paths:
@@ -282,14 +140,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
282
140
  requirements:
283
141
  - - ">="
284
142
  - !ruby/object:Gem::Version
285
- version: '2.7'
143
+ version: '3.0'
286
144
  required_rubygems_version: !ruby/object:Gem::Requirement
287
145
  requirements:
288
146
  - - ">="
289
147
  - !ruby/object:Gem::Version
290
148
  version: '0'
291
149
  requirements: []
292
- rubygems_version: 3.3.20
150
+ rubygems_version: 3.5.9
293
151
  signing_key:
294
152
  specification_version: 4
295
153
  summary: Support for database functions and triggers in Rails migrations
@@ -1,43 +0,0 @@
1
- module Fx
2
- module CommandRecorder
3
- # @api private
4
- class Arguments
5
- def initialize(args)
6
- @args = args.freeze
7
- end
8
-
9
- def function
10
- @args[0]
11
- end
12
-
13
- def version
14
- options[:version]
15
- end
16
-
17
- def revert_to_version
18
- options[:revert_to_version]
19
- end
20
-
21
- def invert_version
22
- Arguments.new([function, options_for_revert])
23
- end
24
-
25
- def to_a
26
- @args.to_a
27
- end
28
-
29
- private
30
-
31
- def options
32
- @options ||= @args[1] || {}
33
- end
34
-
35
- def options_for_revert
36
- options.clone.tap do |revert_options|
37
- revert_options[:version] = revert_to_version
38
- revert_options.delete(:revert_to_version)
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,30 +0,0 @@
1
- module Fx
2
- module CommandRecorder
3
- # @api private
4
- module Function
5
- def create_function(*args)
6
- record(:create_function, args)
7
- end
8
-
9
- def drop_function(*args)
10
- record(:drop_function, args)
11
- end
12
-
13
- def update_function(*args)
14
- record(:update_function, args)
15
- end
16
-
17
- def invert_create_function(args)
18
- [:drop_function, args]
19
- end
20
-
21
- def invert_drop_function(args)
22
- perform_inversion(:create_function, args)
23
- end
24
-
25
- def invert_update_function(args)
26
- perform_inversion(:update_function, args)
27
- end
28
- end
29
- end
30
- end
@@ -1,30 +0,0 @@
1
- module Fx
2
- module CommandRecorder
3
- # @api private
4
- module Trigger
5
- def create_trigger(*args)
6
- record(:create_trigger, args)
7
- end
8
-
9
- def drop_trigger(*args)
10
- record(:drop_trigger, args)
11
- end
12
-
13
- def update_trigger(*args)
14
- record(:update_trigger, args)
15
- end
16
-
17
- def invert_create_trigger(args)
18
- [:drop_trigger, args]
19
- end
20
-
21
- def invert_drop_trigger(args)
22
- perform_inversion(:create_trigger, args)
23
- end
24
-
25
- def invert_update_trigger(args)
26
- perform_inversion(:update_trigger, args)
27
- end
28
- end
29
- end
30
- end
@@ -1,38 +0,0 @@
1
- require "rails"
2
-
3
- module Fx
4
- module SchemaDumper
5
- # @api private
6
- module Function
7
- def tables(stream)
8
- if Fx.configuration.dump_functions_at_beginning_of_schema
9
- functions(stream)
10
- empty_line(stream)
11
- end
12
-
13
- super
14
-
15
- unless Fx.configuration.dump_functions_at_beginning_of_schema
16
- functions(stream)
17
- empty_line(stream)
18
- end
19
- end
20
-
21
- def empty_line(stream)
22
- stream.puts if dumpable_functions_in_database.any?
23
- end
24
-
25
- def functions(stream)
26
- dumpable_functions_in_database.each do |function|
27
- stream.puts(function.to_schema)
28
- end
29
- end
30
-
31
- private
32
-
33
- def dumpable_functions_in_database
34
- @_dumpable_functions_in_database ||= Fx.database.functions
35
- end
36
- end
37
- end
38
- end
@@ -1,29 +0,0 @@
1
- require "rails"
2
-
3
- module Fx
4
- module SchemaDumper
5
- # @api private
6
- module Trigger
7
- def tables(stream)
8
- super
9
- triggers(stream)
10
- end
11
-
12
- def triggers(stream)
13
- if dumpable_triggers_in_database.any?
14
- stream.puts
15
- end
16
-
17
- dumpable_triggers_in_database.each do |trigger|
18
- stream.puts(trigger.to_schema)
19
- end
20
- end
21
-
22
- private
23
-
24
- def dumpable_triggers_in_database
25
- @_dumpable_triggers_in_database ||= Fx.database.triggers
26
- end
27
- end
28
- end
29
- end