hairtrigger 0.2.20 → 0.2.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hair_trigger.rb +9 -3
- data/lib/hair_trigger/version.rb +1 -1
- data/spec/adapter_spec.rb +3 -4
- data/spec/migrations-3.2/20110331212003_initial_tables.rb +4 -4
- data/spec/migrations-3.2/20110331212631_user_trigger.rb +1 -1
- data/spec/migrations-3.2/20110417185102_manual_user_trigger.rb +1 -1
- data/spec/migrations-pre-3.1/20110331212003_initial_tables.rb +4 -4
- data/spec/migrations-pre-3.1/20110331212631_user_trigger.rb +1 -1
- data/spec/migrations-pre-3.1/20110417185102_manual_user_trigger.rb +1 -1
- data/spec/migrations/20110331212003_initial_tables.rb +4 -4
- data/spec/migrations/20110331212631_user_trigger.rb +1 -1
- data/spec/migrations/20110417185102_manual_user_trigger.rb +1 -1
- data/spec/models/user.rb +2 -2
- data/spec/models/user_group.rb +3 -0
- data/spec/schema_dumper_spec.rb +4 -4
- data/spec/spec_helper.rb +3 -2
- metadata +4 -4
- data/spec/models/group.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f20c9f46678e0f212a8dddf861f0872609c4a519
|
4
|
+
data.tar.gz: 3dd34ed254df8230ff6ffd32020be89d9b63c386
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8db4cbe050c37d6aed248679e72770767e4b1b05812f8dc704ae2234e02ff5c7a8d38e3f4663ef23642b9c2aa3d39d18a813b73eb3f5ccc25cc24b5019170ca
|
7
|
+
data.tar.gz: 827a7536fcee643bc4652a6cb7b073e13ab182b1b03f69bf80b63deb63f7618c6b564d3a91df5fa48acda4059f3e8c7eed03eb06510c79e4ed45d3aa7ffa6794
|
data/lib/hair_trigger.rb
CHANGED
@@ -41,9 +41,15 @@ module HairTrigger
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def migrator
|
44
|
-
|
45
|
-
|
46
|
-
migration_path
|
44
|
+
version = ActiveRecord::VERSION::STRING
|
45
|
+
if version >= "5.2."
|
46
|
+
migrations = ActiveRecord::MigrationContext.new(migration_path).migrations
|
47
|
+
elsif version < "4.0."
|
48
|
+
migrations = migration_path
|
49
|
+
else # version >= "4.0."
|
50
|
+
migrations = ActiveRecord::Migrator.migrations(migration_path)
|
51
|
+
end
|
52
|
+
|
47
53
|
ActiveRecord::Migrator.new(:up, migrations)
|
48
54
|
end
|
49
55
|
|
data/lib/hair_trigger/version.rb
CHANGED
data/spec/adapter_spec.rb
CHANGED
@@ -37,7 +37,7 @@ describe "adapter" do
|
|
37
37
|
CREATE TRIGGER foos_tr AFTER DELETE ON users
|
38
38
|
FOR EACH ROW
|
39
39
|
BEGIN
|
40
|
-
UPDATE
|
40
|
+
UPDATE user_groups SET bob_count = bob_count - 1;
|
41
41
|
END
|
42
42
|
SQL
|
43
43
|
|
@@ -63,7 +63,7 @@ describe "adapter" do
|
|
63
63
|
CREATE FUNCTION foos_tr()
|
64
64
|
RETURNS TRIGGER AS $$
|
65
65
|
BEGIN
|
66
|
-
UPDATE
|
66
|
+
UPDATE user_groups SET bob_count = bob_count - 1;
|
67
67
|
END;
|
68
68
|
$$ LANGUAGE plpgsql;
|
69
69
|
|
@@ -83,7 +83,7 @@ describe "adapter" do
|
|
83
83
|
CREATE TRIGGER foos_tr AFTER DELETE ON users
|
84
84
|
FOR EACH ROW
|
85
85
|
BEGIN
|
86
|
-
UPDATE
|
86
|
+
UPDATE user_groups SET bob_count = bob_count - 1;
|
87
87
|
END;
|
88
88
|
SQL
|
89
89
|
|
@@ -92,4 +92,3 @@ describe "adapter" do
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
end
|
95
|
-
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class InitialTables < ActiveRecord::Migration
|
2
2
|
def up
|
3
3
|
create_table "users" do |t|
|
4
|
-
t.integer "
|
4
|
+
t.integer "user_group_id"
|
5
5
|
t.string "name"
|
6
6
|
end
|
7
7
|
|
8
|
-
create_table "
|
8
|
+
create_table "user_groups" do |t|
|
9
9
|
t.integer "bob_count", :default => 0
|
10
10
|
t.integer "updated_joe_count", :default => 0
|
11
11
|
end
|
@@ -13,6 +13,6 @@ class InitialTables < ActiveRecord::Migration
|
|
13
13
|
|
14
14
|
def down
|
15
15
|
drop_table "users"
|
16
|
-
drop_table "
|
16
|
+
drop_table "user_groups"
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class InitialTables < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
3
|
create_table "users" do |t|
|
4
|
-
t.integer "
|
4
|
+
t.integer "user_group_id"
|
5
5
|
t.string "name"
|
6
6
|
end
|
7
7
|
|
8
|
-
create_table "
|
8
|
+
create_table "user_groups" do |t|
|
9
9
|
t.integer "bob_count", :default => 0
|
10
10
|
t.integer "updated_joe_count", :default => 0
|
11
11
|
end
|
@@ -13,6 +13,6 @@ class InitialTables < ActiveRecord::Migration
|
|
13
13
|
|
14
14
|
def self.down
|
15
15
|
drop_table "users"
|
16
|
-
drop_table "
|
16
|
+
drop_table "user_groups"
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class InitialTables < ActiveRecord::Migration[5.0]
|
2
2
|
def up
|
3
3
|
create_table "users" do |t|
|
4
|
-
t.integer "
|
4
|
+
t.integer "user_group_id"
|
5
5
|
t.string "name"
|
6
6
|
end
|
7
7
|
|
8
|
-
create_table "
|
8
|
+
create_table "user_groups" do |t|
|
9
9
|
t.integer "bob_count", :default => 0
|
10
10
|
t.integer "updated_joe_count", :default => 0
|
11
11
|
end
|
@@ -13,6 +13,6 @@ class InitialTables < ActiveRecord::Migration[5.0]
|
|
13
13
|
|
14
14
|
def down
|
15
15
|
drop_table "users"
|
16
|
-
drop_table "
|
16
|
+
drop_table "user_groups"
|
17
17
|
end
|
18
|
-
end
|
18
|
+
end
|
@@ -4,7 +4,7 @@ class ManualUserTrigger < ActiveRecord::Migration[5.0]
|
|
4
4
|
on("users").
|
5
5
|
after(:update).
|
6
6
|
where("NEW.name = 'joe'") do
|
7
|
-
"UPDATE
|
7
|
+
"UPDATE user_groups SET updated_joe_count = updated_joe_count + 1"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
data/spec/models/user.rb
CHANGED
data/spec/schema_dumper_spec.rb
CHANGED
@@ -32,8 +32,8 @@ describe "schema dumping" do
|
|
32
32
|
it "should not dump triggers in migrations that haven't run" do
|
33
33
|
# edit our model trigger, generate a new migration
|
34
34
|
replace_file_contents HairTrigger.model_path + '/user.rb',
|
35
|
-
'"UPDATE
|
36
|
-
'{:default => "UPDATE
|
35
|
+
'"UPDATE user_groups SET bob_count = bob_count + 1"',
|
36
|
+
'{:default => "UPDATE user_groups SET bob_count = bob_count + 2"}'
|
37
37
|
reset_models
|
38
38
|
|
39
39
|
HairTrigger.should_not be_migrations_current
|
@@ -87,8 +87,8 @@ describe "schema dumping" do
|
|
87
87
|
it "should evaluate all migrations even if they haven't run" do
|
88
88
|
# edit our model trigger, generate a new migration
|
89
89
|
replace_file_contents HairTrigger.model_path + '/user.rb',
|
90
|
-
'"UPDATE
|
91
|
-
'{:default => "UPDATE
|
90
|
+
'"UPDATE user_groups SET bob_count = bob_count + 1"',
|
91
|
+
'{:default => "UPDATE user_groups SET bob_count = bob_count + 2"}'
|
92
92
|
reset_models
|
93
93
|
|
94
94
|
HairTrigger.should_not be_migrations_current
|
data/spec/spec_helper.rb
CHANGED
@@ -60,8 +60,9 @@ shared_context "hairtrigger utils" do
|
|
60
60
|
ret = `echo "drop database if exists #{config['database']}; create database #{config['database']};" | mysql -u #{config['username']}`
|
61
61
|
raise "error creating database: #{ret}" unless $?.exitstatus == 0
|
62
62
|
when :postgresql
|
63
|
-
|
64
|
-
|
63
|
+
user_arg = "-U #{config['username']}" if config['username']
|
64
|
+
`dropdb #{user_arg} #{config['database']} &>/dev/null`
|
65
|
+
ret = `createdb #{user_arg} #{config['database']} 2>&1`
|
65
66
|
raise "error creating database: #{ret}" unless $?.exitstatus == 0
|
66
67
|
end
|
67
68
|
# Arel has an issue in that it keeps using original connection for quoting,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hairtrigger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Jensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -85,8 +85,8 @@ files:
|
|
85
85
|
- spec/migrations/20110331212631_user_trigger.rb
|
86
86
|
- spec/migrations/20110417185102_manual_user_trigger.rb
|
87
87
|
- spec/migrations_spec.rb
|
88
|
-
- spec/models/group.rb
|
89
88
|
- spec/models/user.rb
|
89
|
+
- spec/models/user_group.rb
|
90
90
|
- spec/schema_dumper_spec.rb
|
91
91
|
- spec/spec_helper.rb
|
92
92
|
homepage: http://github.com/jenseng/hair_trigger
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: 1.3.5
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.6.
|
112
|
+
rubygems_version: 2.6.13
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: easy database triggers for active record
|
data/spec/models/group.rb
DELETED