culturecode_stagehand 0.7.9 → 0.7.10

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: 7a3605105f16b08844ff35d898d5043a4fa7c733
4
- data.tar.gz: 9cbedc3a329392ab269dc0cb8ffbe88a65182117
3
+ metadata.gz: eb03c8a33d965513648b4e8acaca9e956b4d4bdf
4
+ data.tar.gz: 19882d1cdeed12d6fda5e101676784829ed47a48
5
5
  SHA512:
6
- metadata.gz: 7644db9843c467270b6afd416c00e1a110ad0098a848d8982082bd63dae120dd255c5866ba4073573ad1f4523b3211b8da71256da7b9fa6e7566fc9d8027d8ea
7
- data.tar.gz: 83d51fba48b3190b20cf02df0876db946b87ea198911c0740d2016ae55cc1a4f650d0f502e463be9f8f55ba8137fe5b3bf98316c9460af965bc051b88f0f986a
6
+ metadata.gz: b6afe7cd3824becaeb9c718650155b5128676fcb78f13514ffc24b9fd3554fc9cc2ba60edd5ba63111276dd2df21786637f7a4587b8238d7786a18f0c015013d
7
+ data.tar.gz: 2af88daac9cc6828250b3f3429d0534c8c7a567d8ccc1b12f2ef8c3abe08e386d449ae0d705027a989282549758eeb96c624cec07fd90d371a351c1c7877c10f
@@ -28,6 +28,14 @@ module Stagehand
28
28
  database_name(Configuration.staging_connection_name)
29
29
  end
30
30
 
31
+ def staging_database_versions
32
+ Stagehand::Database.staging_connection.select_values(versions_scope)
33
+ end
34
+
35
+ def production_database_versions
36
+ Stagehand::Database.production_connection.select_values(versions_scope)
37
+ end
38
+
31
39
  def with_connection(connection_name)
32
40
  different = current_connection_name != connection_name.to_sym
33
41
 
@@ -60,6 +68,10 @@ module Stagehand
60
68
  Rails.configuration.database_configuration[connection_name.to_s]['database']
61
69
  end
62
70
 
71
+ def versions_scope
72
+ ActiveRecord::SchemaMigration.order(:version)
73
+ end
74
+
63
75
  # CLASSES
64
76
 
65
77
  class StagingProbe < ActiveRecord::Base
@@ -129,7 +129,7 @@ module Stagehand
129
129
  end
130
130
 
131
131
  def affected_records
132
- cache(:affected_records) { affected_entries.collect(&:record).uniq }
132
+ cache(:affected_records) { affected_entries.uniq(&:key).collect(&:record).compact }
133
133
  end
134
134
 
135
135
  def affected_entries
@@ -60,6 +60,13 @@ module Stagehand
60
60
  sync_checklist(Checklist.new(record))
61
61
  end
62
62
 
63
+ def sync_checklist(checklist)
64
+ ActiveRecord::Base.transaction do
65
+ sync_entries(checklist.syncing_entries)
66
+ CommitEntry.delete(checklist.affected_entries)
67
+ end
68
+ end
69
+
63
70
  private
64
71
 
65
72
  # Lazily iterate through millions of commit entries
@@ -94,13 +101,6 @@ module Stagehand
94
101
  return entries
95
102
  end
96
103
 
97
- def sync_checklist(checklist)
98
- ActiveRecord::Base.transaction do
99
- sync_entries(checklist.syncing_entries)
100
- CommitEntry.delete(checklist.affected_entries)
101
- end
102
- end
103
-
104
104
  def sync_entries(entries)
105
105
  raise SchemaMismatch unless schemas_match?
106
106
 
@@ -124,12 +124,7 @@ module Stagehand
124
124
 
125
125
  def schemas_match?
126
126
  return schemas_match unless schemas_match.nil?
127
-
128
- versions_scope = ActiveRecord::SchemaMigration.order(:version)
129
- staging_versions = Stagehand::Database.staging_connection.select_values(versions_scope)
130
- production_versions = Stagehand::Database.production_connection.select_values(versions_scope)
131
- self.schemas_match = staging_versions == production_versions
132
-
127
+ self.schemas_match = Database.staging_database_versions == Database.production_database_versions
133
128
  return schemas_match
134
129
  end
135
130
 
@@ -1,3 +1,3 @@
1
1
  module Stagehand
2
- VERSION = "0.7.9"
2
+ VERSION = "0.7.10"
3
3
  end
@@ -18,14 +18,14 @@ namespace :stagehand do
18
18
  desc "Migrate both databases used by stagehand"
19
19
  task :migrate => :environment do
20
20
  run_on_both_databases do
21
- ActiveRecord::Migrator.migrate('db/migrate')
21
+ ActiveRecord::Migrator.migrate("#{Rails.root}/db/migrate")
22
22
  end
23
23
  end
24
24
 
25
25
  desc "Rollback both databases used by stagehand"
26
26
  task :rollback => :environment do
27
27
  run_on_both_databases do
28
- ActiveRecord::Migrator.rollback("db/migrate")
28
+ ActiveRecord::Migrator.rollback("#{Rails.root}/db/migrate")
29
29
  end
30
30
  end
31
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: culturecode_stagehand
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.7.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Jakobsen