fx 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/gemfiles/rails40.gemfile.lock +21 -21
- data/gemfiles/rails41.gemfile.lock +22 -22
- data/gemfiles/rails42.gemfile.lock +25 -25
- data/gemfiles/rails50.gemfile.lock +1 -1
- data/lib/fx/adapters/postgres/functions.rb +2 -1
- data/lib/fx/adapters/postgres/triggers.rb +2 -1
- data/lib/fx/version.rb +1 -1
- data/lib/generators/fx/function/function_generator.rb +8 -0
- data/lib/generators/fx/function/templates/db/migrate/create_function.erb +1 -1
- data/lib/generators/fx/function/templates/db/migrate/update_function.erb +1 -1
- data/lib/generators/fx/trigger/templates/db/migrate/create_trigger.erb +1 -1
- data/lib/generators/fx/trigger/templates/db/migrate/update_trigger.erb +1 -1
- data/lib/generators/fx/trigger/trigger_generator.rb +8 -0
- data/spec/features/functions/migrations_spec.rb +3 -3
- data/spec/features/functions/revert_spec.rb +4 -4
- data/spec/features/triggers/migrations_spec.rb +2 -2
- data/spec/features/triggers/revert_spec.rb +4 -4
- data/spec/support/migration_helpers.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6938f7995ea791b0cae6efb9198d707e1c844933
|
|
4
|
+
data.tar.gz: 3f636e55ea8dc7c4d858ba4f178233eafe2af09a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 024d66a1780024f26d6ba5b8e619d398e9d30a838a7427a13b054b63e7376baf8c530251ace8ab74c963772c191aeca7b2f65212024e6a9eb3a2e2dd0574701e
|
|
7
|
+
data.tar.gz: b28ac249704b43766fd76e9110d1fee6c1098c3811d6736f3eb56a23a1fc043a5d40e159cb969edf103cc66e51b8861c5a1167650d44eded8e7bdba6f5a68922
|
|
@@ -60,29 +60,29 @@ GEM
|
|
|
60
60
|
activesupport (= 4.0.13)
|
|
61
61
|
rake (>= 0.8.7)
|
|
62
62
|
thor (>= 0.18.1, < 2.0)
|
|
63
|
-
rake (11.
|
|
63
|
+
rake (11.2.2)
|
|
64
64
|
redcarpet (3.3.4)
|
|
65
|
-
rspec (3.
|
|
66
|
-
rspec-core (~> 3.
|
|
67
|
-
rspec-expectations (~> 3.
|
|
68
|
-
rspec-mocks (~> 3.
|
|
69
|
-
rspec-core (3.
|
|
70
|
-
rspec-support (~> 3.
|
|
71
|
-
rspec-expectations (3.
|
|
65
|
+
rspec (3.5.0)
|
|
66
|
+
rspec-core (~> 3.5.0)
|
|
67
|
+
rspec-expectations (~> 3.5.0)
|
|
68
|
+
rspec-mocks (~> 3.5.0)
|
|
69
|
+
rspec-core (3.5.4)
|
|
70
|
+
rspec-support (~> 3.5.0)
|
|
71
|
+
rspec-expectations (3.5.0)
|
|
72
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
73
|
-
rspec-support (~> 3.
|
|
74
|
-
rspec-mocks (3.
|
|
73
|
+
rspec-support (~> 3.5.0)
|
|
74
|
+
rspec-mocks (3.5.0)
|
|
75
75
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
76
|
-
rspec-support (~> 3.
|
|
77
|
-
rspec-rails (3.
|
|
78
|
-
actionpack (>= 3.0
|
|
79
|
-
activesupport (>= 3.0
|
|
80
|
-
railties (>= 3.0
|
|
81
|
-
rspec-core (~> 3.
|
|
82
|
-
rspec-expectations (~> 3.
|
|
83
|
-
rspec-mocks (~> 3.
|
|
84
|
-
rspec-support (~> 3.
|
|
85
|
-
rspec-support (3.
|
|
76
|
+
rspec-support (~> 3.5.0)
|
|
77
|
+
rspec-rails (3.5.2)
|
|
78
|
+
actionpack (>= 3.0)
|
|
79
|
+
activesupport (>= 3.0)
|
|
80
|
+
railties (>= 3.0)
|
|
81
|
+
rspec-core (~> 3.5.0)
|
|
82
|
+
rspec-expectations (~> 3.5.0)
|
|
83
|
+
rspec-mocks (~> 3.5.0)
|
|
84
|
+
rspec-support (~> 3.5.0)
|
|
85
|
+
rspec-support (3.5.0)
|
|
86
86
|
slop (3.6.0)
|
|
87
87
|
thor (0.19.1)
|
|
88
88
|
thread_safe (0.3.5)
|
|
@@ -108,4 +108,4 @@ DEPENDENCIES
|
|
|
108
108
|
yard
|
|
109
109
|
|
|
110
110
|
BUNDLED WITH
|
|
111
|
-
1.
|
|
111
|
+
1.13.6
|
|
@@ -47,7 +47,7 @@ GEM
|
|
|
47
47
|
i18n (0.7.0)
|
|
48
48
|
json (1.8.3)
|
|
49
49
|
method_source (0.8.2)
|
|
50
|
-
minitest (5.9.
|
|
50
|
+
minitest (5.9.1)
|
|
51
51
|
pg (0.18.4)
|
|
52
52
|
pry (0.10.3)
|
|
53
53
|
coderay (~> 1.1.0)
|
|
@@ -61,29 +61,29 @@ GEM
|
|
|
61
61
|
activesupport (= 4.1.15)
|
|
62
62
|
rake (>= 0.8.7)
|
|
63
63
|
thor (>= 0.18.1, < 2.0)
|
|
64
|
-
rake (11.
|
|
64
|
+
rake (11.2.2)
|
|
65
65
|
redcarpet (3.3.4)
|
|
66
|
-
rspec (3.
|
|
67
|
-
rspec-core (~> 3.
|
|
68
|
-
rspec-expectations (~> 3.
|
|
69
|
-
rspec-mocks (~> 3.
|
|
70
|
-
rspec-core (3.
|
|
71
|
-
rspec-support (~> 3.
|
|
72
|
-
rspec-expectations (3.
|
|
66
|
+
rspec (3.5.0)
|
|
67
|
+
rspec-core (~> 3.5.0)
|
|
68
|
+
rspec-expectations (~> 3.5.0)
|
|
69
|
+
rspec-mocks (~> 3.5.0)
|
|
70
|
+
rspec-core (3.5.4)
|
|
71
|
+
rspec-support (~> 3.5.0)
|
|
72
|
+
rspec-expectations (3.5.0)
|
|
73
73
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
74
|
-
rspec-support (~> 3.
|
|
75
|
-
rspec-mocks (3.
|
|
74
|
+
rspec-support (~> 3.5.0)
|
|
75
|
+
rspec-mocks (3.5.0)
|
|
76
76
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
77
|
-
rspec-support (~> 3.
|
|
78
|
-
rspec-rails (3.
|
|
79
|
-
actionpack (>= 3.0
|
|
80
|
-
activesupport (>= 3.0
|
|
81
|
-
railties (>= 3.0
|
|
82
|
-
rspec-core (~> 3.
|
|
83
|
-
rspec-expectations (~> 3.
|
|
84
|
-
rspec-mocks (~> 3.
|
|
85
|
-
rspec-support (~> 3.
|
|
86
|
-
rspec-support (3.
|
|
77
|
+
rspec-support (~> 3.5.0)
|
|
78
|
+
rspec-rails (3.5.2)
|
|
79
|
+
actionpack (>= 3.0)
|
|
80
|
+
activesupport (>= 3.0)
|
|
81
|
+
railties (>= 3.0)
|
|
82
|
+
rspec-core (~> 3.5.0)
|
|
83
|
+
rspec-expectations (~> 3.5.0)
|
|
84
|
+
rspec-mocks (~> 3.5.0)
|
|
85
|
+
rspec-support (~> 3.5.0)
|
|
86
|
+
rspec-support (3.5.0)
|
|
87
87
|
slop (3.6.0)
|
|
88
88
|
thor (0.19.1)
|
|
89
89
|
thread_safe (0.3.5)
|
|
@@ -110,4 +110,4 @@ DEPENDENCIES
|
|
|
110
110
|
yard
|
|
111
111
|
|
|
112
112
|
BUNDLED WITH
|
|
113
|
-
1.
|
|
113
|
+
1.13.6
|
|
@@ -53,10 +53,10 @@ GEM
|
|
|
53
53
|
loofah (2.0.3)
|
|
54
54
|
nokogiri (>= 1.5.9)
|
|
55
55
|
method_source (0.8.2)
|
|
56
|
-
mini_portile2 (2.
|
|
57
|
-
minitest (5.9.
|
|
58
|
-
nokogiri (1.6.
|
|
59
|
-
mini_portile2 (~> 2.
|
|
56
|
+
mini_portile2 (2.1.0)
|
|
57
|
+
minitest (5.9.1)
|
|
58
|
+
nokogiri (1.6.8.1)
|
|
59
|
+
mini_portile2 (~> 2.1.0)
|
|
60
60
|
pg (0.18.4)
|
|
61
61
|
pry (0.10.3)
|
|
62
62
|
coderay (~> 1.1.0)
|
|
@@ -78,29 +78,29 @@ GEM
|
|
|
78
78
|
activesupport (= 4.2.6)
|
|
79
79
|
rake (>= 0.8.7)
|
|
80
80
|
thor (>= 0.18.1, < 2.0)
|
|
81
|
-
rake (11.
|
|
81
|
+
rake (11.2.2)
|
|
82
82
|
redcarpet (3.3.4)
|
|
83
|
-
rspec (3.
|
|
84
|
-
rspec-core (~> 3.
|
|
85
|
-
rspec-expectations (~> 3.
|
|
86
|
-
rspec-mocks (~> 3.
|
|
87
|
-
rspec-core (3.
|
|
88
|
-
rspec-support (~> 3.
|
|
89
|
-
rspec-expectations (3.
|
|
83
|
+
rspec (3.5.0)
|
|
84
|
+
rspec-core (~> 3.5.0)
|
|
85
|
+
rspec-expectations (~> 3.5.0)
|
|
86
|
+
rspec-mocks (~> 3.5.0)
|
|
87
|
+
rspec-core (3.5.4)
|
|
88
|
+
rspec-support (~> 3.5.0)
|
|
89
|
+
rspec-expectations (3.5.0)
|
|
90
90
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
91
|
-
rspec-support (~> 3.
|
|
92
|
-
rspec-mocks (3.
|
|
91
|
+
rspec-support (~> 3.5.0)
|
|
92
|
+
rspec-mocks (3.5.0)
|
|
93
93
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
94
|
-
rspec-support (~> 3.
|
|
95
|
-
rspec-rails (3.
|
|
96
|
-
actionpack (>= 3.0
|
|
97
|
-
activesupport (>= 3.0
|
|
98
|
-
railties (>= 3.0
|
|
99
|
-
rspec-core (~> 3.
|
|
100
|
-
rspec-expectations (~> 3.
|
|
101
|
-
rspec-mocks (~> 3.
|
|
102
|
-
rspec-support (~> 3.
|
|
103
|
-
rspec-support (3.
|
|
94
|
+
rspec-support (~> 3.5.0)
|
|
95
|
+
rspec-rails (3.5.2)
|
|
96
|
+
actionpack (>= 3.0)
|
|
97
|
+
activesupport (>= 3.0)
|
|
98
|
+
railties (>= 3.0)
|
|
99
|
+
rspec-core (~> 3.5.0)
|
|
100
|
+
rspec-expectations (~> 3.5.0)
|
|
101
|
+
rspec-mocks (~> 3.5.0)
|
|
102
|
+
rspec-support (~> 3.5.0)
|
|
103
|
+
rspec-support (3.5.0)
|
|
104
104
|
slop (3.6.0)
|
|
105
105
|
thor (0.19.1)
|
|
106
106
|
thread_safe (0.3.5)
|
|
@@ -127,4 +127,4 @@ DEPENDENCIES
|
|
|
127
127
|
yard
|
|
128
128
|
|
|
129
129
|
BUNDLED WITH
|
|
130
|
-
1.
|
|
130
|
+
1.13.6
|
|
@@ -17,7 +17,8 @@ module Fx
|
|
|
17
17
|
ON pn.oid = pp.pronamespace
|
|
18
18
|
LEFT JOIN pg_depend pd
|
|
19
19
|
ON pd.objid = pp.oid AND pd.deptype = 'e'
|
|
20
|
-
WHERE pn.nspname = 'public' AND pd.objid IS NULL
|
|
20
|
+
WHERE pn.nspname = 'public' AND pd.objid IS NULL
|
|
21
|
+
ORDER BY pp.oid;
|
|
21
22
|
SQL
|
|
22
23
|
|
|
23
24
|
# Wraps #all as a static facade.
|
data/lib/fx/version.rb
CHANGED
|
@@ -59,6 +59,14 @@ module Fx
|
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
def activerecord_migration_class
|
|
63
|
+
if ActiveRecord::Migration.respond_to?(:current_version)
|
|
64
|
+
"ActiveRecord::Migration[5.0]"
|
|
65
|
+
else
|
|
66
|
+
"ActiveRecord::Migration"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
62
70
|
def formatted_name
|
|
63
71
|
if singular_name.include?(".")
|
|
64
72
|
"\"#{singular_name}\""
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class <%= migration_class_name %> <
|
|
1
|
+
class <%= migration_class_name %> < <%= activerecord_migration_class %>
|
|
2
2
|
def change
|
|
3
3
|
update_trigger <%= formatted_name %>, on: <%= formatted_table_name %>, version: <%= version %>, revert_to_version: <%= previous_version %>
|
|
4
4
|
end
|
|
@@ -56,6 +56,14 @@ module Fx
|
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
|
|
59
|
+
def activerecord_migration_class
|
|
60
|
+
if ActiveRecord::Migration.respond_to?(:current_version)
|
|
61
|
+
"ActiveRecord::Migration[5.0]"
|
|
62
|
+
else
|
|
63
|
+
"ActiveRecord::Migration"
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
59
67
|
def formatted_name
|
|
60
68
|
if singular_name.include?(".")
|
|
61
69
|
"\"#{singular_name}\""
|
|
@@ -16,7 +16,7 @@ describe "Function migrations", :db do
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "can run migrations that create functions" do
|
|
19
|
-
migration = Class.new(
|
|
19
|
+
migration = Class.new(migration_class) do
|
|
20
20
|
def up
|
|
21
21
|
create_function :test
|
|
22
22
|
end
|
|
@@ -28,7 +28,7 @@ describe "Function migrations", :db do
|
|
|
28
28
|
it "can run migrations that drop functions" do
|
|
29
29
|
connection.create_function(:test)
|
|
30
30
|
|
|
31
|
-
migration = Class.new(
|
|
31
|
+
migration = Class.new(migration_class) do
|
|
32
32
|
def up
|
|
33
33
|
drop_function :test
|
|
34
34
|
end
|
|
@@ -53,7 +53,7 @@ describe "Function migrations", :db do
|
|
|
53
53
|
version: 2,
|
|
54
54
|
sql_definition: sql_definition,
|
|
55
55
|
) do
|
|
56
|
-
migration = Class.new(
|
|
56
|
+
migration = Class.new(migration_class) do
|
|
57
57
|
def change
|
|
58
58
|
update_function :test, version: 2, revert_to_version: 1
|
|
59
59
|
end
|
|
@@ -16,7 +16,7 @@ describe "Reverting migrations", :db do
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
it "can run reversible migrations for creating functions" do
|
|
19
|
-
migration = Class.new(
|
|
19
|
+
migration = Class.new(migration_class) do
|
|
20
20
|
def change
|
|
21
21
|
create_function :test
|
|
22
22
|
end
|
|
@@ -28,12 +28,12 @@ describe "Reverting migrations", :db do
|
|
|
28
28
|
it "can run reversible migrations for dropping functions" do
|
|
29
29
|
connection.create_function(:test)
|
|
30
30
|
|
|
31
|
-
good_migration = Class.new(
|
|
31
|
+
good_migration = Class.new(migration_class) do
|
|
32
32
|
def change
|
|
33
33
|
drop_function :test, revert_to_version: 1
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
|
-
bad_migration = Class.new(
|
|
36
|
+
bad_migration = Class.new(migration_class) do
|
|
37
37
|
def change
|
|
38
38
|
drop_function :test
|
|
39
39
|
end
|
|
@@ -63,7 +63,7 @@ describe "Reverting migrations", :db do
|
|
|
63
63
|
version: 2,
|
|
64
64
|
sql_definition: sql_definition,
|
|
65
65
|
) do
|
|
66
|
-
migration = Class.new(
|
|
66
|
+
migration = Class.new(migration_class) do
|
|
67
67
|
def change
|
|
68
68
|
update_function :test, version: 2, revert_to_version: 1
|
|
69
69
|
end
|
|
@@ -33,7 +33,7 @@ describe "Trigger migrations", :db do
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "can run migrations that create triggers" do
|
|
36
|
-
migration = Class.new(
|
|
36
|
+
migration = Class.new(migration_class) do
|
|
37
37
|
def up
|
|
38
38
|
create_trigger :uppercase_users_name
|
|
39
39
|
end
|
|
@@ -45,7 +45,7 @@ describe "Trigger migrations", :db do
|
|
|
45
45
|
it "can run migrations that drop triggers" do
|
|
46
46
|
connection.create_trigger(:uppercase_users_name)
|
|
47
47
|
|
|
48
|
-
migration = Class.new(
|
|
48
|
+
migration = Class.new(migration_class) do
|
|
49
49
|
def up
|
|
50
50
|
drop_trigger :uppercase_users_name, on: :users
|
|
51
51
|
end
|
|
@@ -33,7 +33,7 @@ describe "Reverting migrations", :db do
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
it "can run reversible migrations for creating triggers" do
|
|
36
|
-
migration = Class.new(
|
|
36
|
+
migration = Class.new(migration_class) do
|
|
37
37
|
def change
|
|
38
38
|
create_trigger :uppercase_users_name, on: :users
|
|
39
39
|
end
|
|
@@ -45,12 +45,12 @@ describe "Reverting migrations", :db do
|
|
|
45
45
|
it "can run reversible migrations for dropping triggers" do
|
|
46
46
|
connection.create_trigger(:uppercase_users_name, on: :users)
|
|
47
47
|
|
|
48
|
-
good_migration = Class.new(
|
|
48
|
+
good_migration = Class.new(migration_class) do
|
|
49
49
|
def change
|
|
50
50
|
drop_trigger :uppercase_users_name, on: :users, revert_to_version: 1
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
|
-
bad_migration = Class.new(
|
|
53
|
+
bad_migration = Class.new(migration_class) do
|
|
54
54
|
def change
|
|
55
55
|
drop_trigger :uppercase_users_name, on: :users
|
|
56
56
|
end
|
|
@@ -78,7 +78,7 @@ describe "Reverting migrations", :db do
|
|
|
78
78
|
sql_definition: sql_definition,
|
|
79
79
|
version: 2,
|
|
80
80
|
) do
|
|
81
|
-
migration = Class.new(
|
|
81
|
+
migration = Class.new(migration_class) do
|
|
82
82
|
def change
|
|
83
83
|
update_trigger(
|
|
84
84
|
:uppercase_users_name,
|
|
@@ -7,6 +7,14 @@ module MigrationsHelper
|
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
+
def migration_class
|
|
11
|
+
if Rails::VERSION::MAJOR >= 5
|
|
12
|
+
::ActiveRecord::Migration[5.0]
|
|
13
|
+
else
|
|
14
|
+
::ActiveRecord::Migration
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
10
18
|
def connection
|
|
11
19
|
@_connection ||= ActiveRecord::Base.connection
|
|
12
20
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Teo Ljungberg
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-11-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: appraisal
|