hairtrigger 0.2.20 → 0.2.21

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f8b4e42be78944baeb498703bd62358dc5e496fd
4
- data.tar.gz: 44fffb42e6f6a47afa81b0383b793f75ac93a594
3
+ metadata.gz: f20c9f46678e0f212a8dddf861f0872609c4a519
4
+ data.tar.gz: 3dd34ed254df8230ff6ffd32020be89d9b63c386
5
5
  SHA512:
6
- metadata.gz: 4076623ae117821f499bc3b8854085c2fb9fb107106ff53f2a2a7fb9dd33d4e368181db5817f5f317995486bbd74db343a9c32932432acc3dbff268d6a57a261
7
- data.tar.gz: 07297019167a8320348100210225785d15c9631d37d585f1fcc338b8e782f49b9c088dc024870be3dbdda06e40bca511f7918145c0bc7008f8cc4ed9a71819c8
6
+ metadata.gz: a8db4cbe050c37d6aed248679e72770767e4b1b05812f8dc704ae2234e02ff5c7a8d38e3f4663ef23642b9c2aa3d39d18a813b73eb3f5ccc25cc24b5019170ca
7
+ data.tar.gz: 827a7536fcee643bc4652a6cb7b073e13ab182b1b03f69bf80b63deb63f7618c6b564d3a91df5fa48acda4059f3e8c7eed03eb06510c79e4ed45d3aa7ffa6794
@@ -41,9 +41,15 @@ module HairTrigger
41
41
  end
42
42
 
43
43
  def migrator
44
- migrations = ActiveRecord::VERSION::STRING >= "4.0." ?
45
- ActiveRecord::Migrator.migrations(migration_path) :
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
 
@@ -1,5 +1,5 @@
1
1
  module HairTrigger
2
- VERSION = "0.2.20"
2
+ VERSION = "0.2.21"
3
3
 
4
4
  def VERSION.<=>(other)
5
5
  split(/\./).map(&:to_i) <=> other.split(/\./).map(&:to_i)
@@ -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 groups SET bob_count = bob_count - 1;
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 groups SET bob_count = bob_count - 1;
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 groups SET bob_count = bob_count - 1;
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 "group_id"
4
+ t.integer "user_group_id"
5
5
  t.string "name"
6
6
  end
7
7
 
8
- create_table "groups" do |t|
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 "groups"
16
+ drop_table "user_groups"
17
17
  end
18
- end
18
+ end
@@ -8,7 +8,7 @@ class UserTrigger < ActiveRecord::Migration
8
8
  on("users").
9
9
  after(:insert).
10
10
  where("NEW.name = 'bob'") do
11
- "UPDATE groups SET bob_count = bob_count + 1"
11
+ "UPDATE user_groups SET bob_count = bob_count + 1"
12
12
  end
13
13
  end
14
14
 
@@ -4,7 +4,7 @@ class ManualUserTrigger < ActiveRecord::Migration
4
4
  on("users").
5
5
  after(:update).
6
6
  where("NEW.name = 'joe'") do
7
- "UPDATE groups SET updated_joe_count = updated_joe_count + 1"
7
+ "UPDATE user_groups SET updated_joe_count = updated_joe_count + 1"
8
8
  end
9
9
  end
10
10
  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 "group_id"
4
+ t.integer "user_group_id"
5
5
  t.string "name"
6
6
  end
7
7
 
8
- create_table "groups" do |t|
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 "groups"
16
+ drop_table "user_groups"
17
17
  end
18
- end
18
+ end
@@ -8,7 +8,7 @@ class UserTrigger < ActiveRecord::Migration
8
8
  on("users").
9
9
  after(:insert).
10
10
  where("NEW.name = 'bob'") do
11
- "UPDATE groups SET bob_count = bob_count + 1"
11
+ "UPDATE user_groups SET bob_count = bob_count + 1"
12
12
  end
13
13
  end
14
14
 
@@ -4,7 +4,7 @@ class ManualUserTrigger < ActiveRecord::Migration
4
4
  on("users").
5
5
  after(:update).
6
6
  where("NEW.name = 'joe'") do
7
- "UPDATE groups SET updated_joe_count = updated_joe_count + 1"
7
+ "UPDATE user_groups SET updated_joe_count = updated_joe_count + 1"
8
8
  end
9
9
  end
10
10
  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 "group_id"
4
+ t.integer "user_group_id"
5
5
  t.string "name"
6
6
  end
7
7
 
8
- create_table "groups" do |t|
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 "groups"
16
+ drop_table "user_groups"
17
17
  end
18
- end
18
+ end
@@ -8,7 +8,7 @@ class UserTrigger < ActiveRecord::Migration[5.0]
8
8
  on("users").
9
9
  after(:insert).
10
10
  where("NEW.name = 'bob'") do
11
- "UPDATE groups SET bob_count = bob_count + 1"
11
+ "UPDATE user_groups SET bob_count = bob_count + 1"
12
12
  end
13
13
  end
14
14
 
@@ -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 groups SET updated_joe_count = updated_joe_count + 1"
7
+ "UPDATE user_groups SET updated_joe_count = updated_joe_count + 1"
8
8
  end
9
9
  end
10
10
  end
@@ -1,6 +1,6 @@
1
1
  class User < ActiveRecord::Base
2
2
  belongs_to :group
3
3
  trigger.after(:insert).where("NEW.name = 'bob'") do
4
- "UPDATE groups SET bob_count = bob_count + 1"
4
+ "UPDATE user_groups SET bob_count = bob_count + 1"
5
5
  end
6
- end
6
+ end
@@ -0,0 +1,3 @@
1
+ class UserGroup < ActiveRecord::Base
2
+ has_many :users
3
+ end
@@ -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 groups SET bob_count = bob_count + 1"',
36
- '{:default => "UPDATE groups SET bob_count = bob_count + 2"}'
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 groups SET bob_count = bob_count + 1"',
91
- '{:default => "UPDATE groups SET bob_count = bob_count + 2"}'
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
@@ -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
- `dropdb -U #{config['username']} #{config['database']} &>/dev/null`
64
- ret = `createdb -U #{config['username']} #{config['database']} 2>&1`
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.20
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: 2017-08-26 00:00:00.000000000 Z
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.11
112
+ rubygems_version: 2.6.13
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: easy database triggers for active record
@@ -1,3 +0,0 @@
1
- class Group < ActiveRecord::Base
2
- has_many :users
3
- end