culturecode_stagehand 0.1.0 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ba8e79e0039e00f41cb0ac4042c677aeed631f5
4
- data.tar.gz: 962467e5d04f3303c2a184e796a61ec06dcde83a
3
+ metadata.gz: 72f51c6303b63f139ef0af10cd15021907df8a1d
4
+ data.tar.gz: 104d5725ec17b18f858ee42d02cdb08be33406fd
5
5
  SHA512:
6
- metadata.gz: e5aa81f338bacc2eaf0a4926d3b357d92be1ffea5ecd04f4db1365abeeee8729f592c3ee2bfe908d8a76feaaf593632a89b107e7b42e3dac27a37e648f8c98f8
7
- data.tar.gz: 8c1fea3d8ac972451119a1e01797d0ea704c0ec2eed20654306ae59f228e6ae76a4515d53a798583cf1ff2b31f85029db4745a0f93817af99ac51f4ee59a77d5
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
- case options.symbolize_keys[:stagehand]
7
- when true
8
- super
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
@@ -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.add_stagehand!(options = {})
7
+ def self.init_stagehand!(options = {})
8
8
  ActiveRecord::Schema.define do
9
- unless Stagehand::Staging::CommitEntry.table_exists?
10
- create_table :stagehand_commit_entries do |t|
11
- t.integer :record_id
12
- t.string :table_name
13
- t.string :operation, :null => false
14
- t.integer :commit_id
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)
@@ -1,3 +1,3 @@
1
1
  module Stagehand
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.4"
3
3
  end
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.0
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-03-31 00:00:00.000000000 Z
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 sanbox database that can sync content to
56
- a production database. Content changes can be bundled so partial syncs of the database
57
- can occur.
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.jakobsen@gmail.com
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 sanbox database that can sync content to a production
109
- database
110
+ summary: Simplify the management of a sandbox database that can sync content to a
111
+ production database
110
112
  test_files: []