culturecode_stagehand 0.1.0 → 0.1.4
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/lib/stagehand/schema/statements.rb +3 -11
- data/lib/stagehand/schema.rb +24 -18
- data/lib/stagehand/version.rb +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72f51c6303b63f139ef0af10cd15021907df8a1d
|
4
|
+
data.tar.gz: 104d5725ec17b18f858ee42d02cdb08be33406fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce29783f1db29d1fbe6575d35a9335cca2ae38eb3cefa5f87f1403bb01faa7afbe9660a9d8823e687bd4e77b6035409118756a51e55d9399daa9f2e82c53e911
|
7
|
+
data.tar.gz: b23952031a353d566de6c590d55ca5be648e3b0cd868b77b204139326c43def85065cbb8467616461321257b00dca01fa0a4af28a2f533d2febbb728958df2bc
|
@@ -3,22 +3,14 @@ module Stagehand
|
|
3
3
|
module Statements
|
4
4
|
# Ensure that developers are aware they need to make a determination of whether stagehand should track this table or not
|
5
5
|
def create_table(table_name, options = {})
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
super
|
7
|
+
|
8
|
+
unless options.symbolize_keys[:stagehand] == false || UNTRACKED_TABLES.include?(table_name)
|
9
9
|
Schema.add_stagehand! :only => table_name
|
10
|
-
when false
|
11
|
-
super
|
12
|
-
else
|
13
|
-
raise TableOptionNotSet, "If this table contains data to sync to the production database, pass #{{:stagehand => true}}" unless UNTRACKED_TABLES.include?(table_name)
|
14
|
-
super
|
15
10
|
end
|
16
11
|
end
|
17
12
|
end
|
18
13
|
end
|
19
|
-
|
20
|
-
# EXCEPTIONS
|
21
|
-
class TableOptionNotSet < ActiveRecord::ActiveRecordError; end
|
22
14
|
end
|
23
15
|
|
24
16
|
ActiveRecord::Base.connection.class.include Stagehand::Schema::Statements
|
data/lib/stagehand/schema.rb
CHANGED
@@ -4,27 +4,33 @@ module Stagehand
|
|
4
4
|
module Schema
|
5
5
|
UNTRACKED_TABLES = ['schema_migrations', Stagehand::Staging::CommitEntry.table_name]
|
6
6
|
|
7
|
-
def self.
|
7
|
+
def self.init_stagehand!(options = {})
|
8
8
|
ActiveRecord::Schema.define do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
t.string :session
|
16
|
-
end
|
17
|
-
|
18
|
-
add_index :stagehand_commit_entries, :commit_id
|
19
|
-
add_index :stagehand_commit_entries, :operation
|
20
|
-
|
21
|
-
# Create trigger to initialize session using a function
|
22
|
-
ActiveRecord::Base.connection.execute("DROP TRIGGER IF EXISTS stagehand_session_trigger;")
|
23
|
-
ActiveRecord::Base.connection.execute("
|
24
|
-
CREATE TRIGGER stagehand_session_trigger BEFORE INSERT ON stagehand_commit_entries
|
25
|
-
FOR EACH ROW SET NEW.session = CONNECTION_ID();")
|
9
|
+
create_table :stagehand_commit_entries do |t|
|
10
|
+
t.integer :record_id
|
11
|
+
t.string :table_name
|
12
|
+
t.string :operation, :null => false
|
13
|
+
t.integer :commit_id
|
14
|
+
t.string :session
|
26
15
|
end
|
27
16
|
|
17
|
+
add_index :stagehand_commit_entries, :commit_id
|
18
|
+
add_index :stagehand_commit_entries, :operation
|
19
|
+
add_index :stagehand_commit_entries, [:record_id, :table_name]
|
20
|
+
|
21
|
+
# Create trigger to initialize session using a function
|
22
|
+
ActiveRecord::Base.connection.execute("DROP TRIGGER IF EXISTS stagehand_session_trigger;")
|
23
|
+
ActiveRecord::Base.connection.execute("
|
24
|
+
CREATE TRIGGER stagehand_session_trigger BEFORE INSERT ON stagehand_commit_entries
|
25
|
+
FOR EACH ROW SET NEW.session = CONNECTION_ID();")
|
26
|
+
end
|
27
|
+
|
28
|
+
add_stagehand!(options)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.add_stagehand!(options = {})
|
32
|
+
ActiveRecord::Schema.define do
|
33
|
+
|
28
34
|
table_names = ActiveRecord::Base.connection.tables
|
29
35
|
table_names -= UNTRACKED_TABLES
|
30
36
|
table_names -= Array(options[:except]).collect(&:to_s)
|
data/lib/stagehand/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: culturecode_stagehand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Jakobsen
|
8
|
+
- Ryan Wallace
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2016-
|
12
|
+
date: 2016-04-01 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rails
|
@@ -52,11 +53,12 @@ dependencies:
|
|
52
53
|
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
55
|
version: '3.0'
|
55
|
-
description: Simplify the management of a
|
56
|
-
a production database. Content changes can be bundled
|
57
|
-
|
56
|
+
description: Simplify the management of a sandbox database that can sync content to
|
57
|
+
a production database. Content changes can be bundled to allow partial syncs of
|
58
|
+
the database.
|
58
59
|
email:
|
59
|
-
- nicholas
|
60
|
+
- nicholas@culturecode.ca
|
61
|
+
- ryan@culturecode.ca
|
60
62
|
executables: []
|
61
63
|
extensions: []
|
62
64
|
extra_rdoc_files: []
|
@@ -105,6 +107,6 @@ rubyforge_project:
|
|
105
107
|
rubygems_version: 2.4.6
|
106
108
|
signing_key:
|
107
109
|
specification_version: 4
|
108
|
-
summary: Simplify the management of a
|
109
|
-
database
|
110
|
+
summary: Simplify the management of a sandbox database that can sync content to a
|
111
|
+
production database
|
110
112
|
test_files: []
|