Empact-trackless_triggers 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/Empact-trackless_triggers.gemspec +1 -1
- data/README +8 -0
- data/VERSION +1 -1
- data/lib/trackless_triggers.rb +6 -2
- metadata +3 -3
data/CHANGELOG
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{Empact-trackless_triggers}
|
8
|
-
s.version = "0.0
|
8
|
+
s.version = "0.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Aaron Patterson", "Christian Eager"]
|
data/README
CHANGED
@@ -16,6 +16,14 @@ Add a trigger:
|
|
16
16
|
:event => 'insert',
|
17
17
|
:statement => 'INSERT INTO log (id, timestamp) VALUES (NEW.id, NOW())'
|
18
18
|
|
19
|
+
Update an existing trigger (drops then adds):
|
20
|
+
|
21
|
+
update_trigger "ai_people",
|
22
|
+
:on => 'people',
|
23
|
+
:timing => 'after',
|
24
|
+
:event => 'insert',
|
25
|
+
:statement => 'INSERT INTO log (id, timestamp) VALUES (NEW.id, NOW())'
|
26
|
+
|
19
27
|
Remove a trigger:
|
20
28
|
|
21
29
|
drop_trigger 'ai_people'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/trackless_triggers.rb
CHANGED
@@ -39,9 +39,13 @@ module ActiveRecord
|
|
39
39
|
end
|
40
40
|
|
41
41
|
module SchemaStatements
|
42
|
+
def update_trigger(name, opts = {})
|
43
|
+
drop_trigger(name)
|
44
|
+
add_trigger(name, opts)
|
45
|
+
end
|
46
|
+
|
42
47
|
def add_trigger(name, opts = {})
|
43
|
-
|
44
|
-
execute sql
|
48
|
+
execute "CREATE TRIGGER #{name} #{opts[:timing]} #{opts[:event]} ON #{opts[:on]} FOR EACH ROW #{opts[:statement]}"
|
45
49
|
end
|
46
50
|
|
47
51
|
def drop_trigger(name)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Empact-trackless_triggers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.8
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Aaron Patterson
|