culturecode_stagehand 0.7.9 → 0.7.10
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/database.rb +12 -0
- data/lib/stagehand/staging/checklist.rb +1 -1
- data/lib/stagehand/staging/synchronizer.rb +8 -13
- data/lib/stagehand/version.rb +1 -1
- data/lib/tasks/stagehand_tasks.rake +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb03c8a33d965513648b4e8acaca9e956b4d4bdf
|
|
4
|
+
data.tar.gz: 19882d1cdeed12d6fda5e101676784829ed47a48
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b6afe7cd3824becaeb9c718650155b5128676fcb78f13514ffc24b9fd3554fc9cc2ba60edd5ba63111276dd2df21786637f7a4587b8238d7786a18f0c015013d
|
|
7
|
+
data.tar.gz: 2af88daac9cc6828250b3f3429d0534c8c7a567d8ccc1b12f2ef8c3abe08e386d449ae0d705027a989282549758eeb96c624cec07fd90d371a351c1c7877c10f
|
data/lib/stagehand/database.rb
CHANGED
|
@@ -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
|
|
@@ -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
|
|
data/lib/stagehand/version.rb
CHANGED
|
@@ -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(
|
|
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
|