storey 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/gemfiles/rails_5.0.gemfile.lock +1 -1
- data/gemfiles/rails_5.1.gemfile.lock +1 -1
- data/gemfiles/rails_5.2.gemfile.lock +1 -1
- data/lib/storey/duplicator.rb +4 -6
- data/lib/storey/get_migration_versions.rb +7 -5
- data/lib/storey/version.rb +1 -1
- data/spec/lib/storey_spec.rb +15 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/storey/duplicator_spec.rb +14 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 077fb1249a3bf984d1613b1351468cebf881bde2ac2e4f299d3b9d17a877d0e5
|
4
|
+
data.tar.gz: 38f7315acb1dcb9c3545a64dca60e67105d6b8520cd276ae1dec8997b4028ec7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d5cc746a06923f49fe9226c8183aaf9a68293a6639a24108fc3b161ab15bf78342bf7124ffa1ac9ded5f4055b75d01be1f815cb67cae65013b6ce12d41b32e6
|
7
|
+
data.tar.gz: 1418cbe848c0e891c5e7c70f05ac5384b79946b9cc878b1e92e918032fbfa36cef8a5209fe89c0a3dcbcea19262cd0a4aea9fcec9e5a3d60d156e2ba36401784
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [2.1.1] - 2018-07-04
|
6
|
+
### Fixed
|
7
|
+
- Fix copying of schemas in when ActiveRecord caches queries
|
8
|
+
|
5
9
|
## [2.1.0] - 2018-07-04
|
6
10
|
### Added
|
7
11
|
- Print duplication stdout for debugging
|
data/lib/storey/duplicator.rb
CHANGED
@@ -96,20 +96,18 @@ module Storey
|
|
96
96
|
def copy_source_schema_migrations
|
97
97
|
::Storey.switch @target_schema do
|
98
98
|
source_schema_migrations.each do |version|
|
99
|
-
|
100
|
-
|
101
|
-
::ActiveRecord::Base.connection.execute command
|
102
|
-
end
|
99
|
+
ActiveRecord::SchemaMigration.where(version: version).
|
100
|
+
first_or_create!
|
103
101
|
end
|
104
102
|
end
|
105
103
|
end
|
106
104
|
|
107
105
|
def source_schema_migrations
|
108
|
-
GetMigrationVersions.(@source_schema)
|
106
|
+
@source_schema_migrations ||= GetMigrationVersions.(@source_schema)
|
109
107
|
end
|
110
108
|
|
111
109
|
def target_schema_migrations
|
112
|
-
GetMigrationVersions.(@target_schema)
|
110
|
+
@target_schema_migrations ||= GetMigrationVersions.(@target_schema)
|
113
111
|
end
|
114
112
|
|
115
113
|
def replace_occurrences
|
@@ -9,11 +9,13 @@ module Storey
|
|
9
9
|
private
|
10
10
|
|
11
11
|
def self.migration_versions
|
12
|
-
|
13
|
-
::ActiveRecord::
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
ActiveRecord::Base.connection.uncached do
|
13
|
+
if Gem::Version.new(ActiveRecord::VERSION::STRING) < Gem::Version.new("5.2")
|
14
|
+
::ActiveRecord::Migrator.get_all_versions
|
15
|
+
else
|
16
|
+
::ActiveRecord::Base.connection.migration_context.
|
17
|
+
get_all_versions
|
18
|
+
end
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
data/lib/storey/version.rb
CHANGED
data/spec/lib/storey_spec.rb
CHANGED
@@ -13,4 +13,19 @@ RSpec.describe Storey do
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
describe ".switch" do
|
17
|
+
it "does not cache between switches" do
|
18
|
+
Storey.create("s1") do
|
19
|
+
2.times {|n| Post.create(name: n.to_s) }
|
20
|
+
end
|
21
|
+
|
22
|
+
Storey.create("s2") do
|
23
|
+
3.times {|n| Post.create(name: n.to_s) }
|
24
|
+
end
|
25
|
+
|
26
|
+
Storey.switch("s1") { expect(Post.count).to eq 2 }
|
27
|
+
Storey.switch("s2") { expect(Post.count).to eq 3 }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
16
31
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -14,6 +14,12 @@ require 'pry'
|
|
14
14
|
RSpec.configure do |config|
|
15
15
|
config.order = 'random'
|
16
16
|
|
17
|
+
config.before(:suite) do
|
18
|
+
# Enable query cache so we can catch unexpected behaviour with AR
|
19
|
+
# caching
|
20
|
+
ActiveRecord::Base.connection.enable_query_cache!
|
21
|
+
end
|
22
|
+
|
17
23
|
config.before(:each) do
|
18
24
|
# We don't want configuration to leak into other tests
|
19
25
|
Storey.reload_config!
|
@@ -27,6 +27,20 @@ describe Storey::Duplicator do
|
|
27
27
|
expect(Dir[source_dump_dir]).to be_empty
|
28
28
|
expect(Dir[target_dump_dir]).to be_empty
|
29
29
|
end
|
30
|
+
|
31
|
+
it "does not used cached schema migration versions when copying" do
|
32
|
+
s1_versions_count = nil
|
33
|
+
Storey.create("s1") do
|
34
|
+
s1_versions_count = ActiveRecord::SchemaMigration.count
|
35
|
+
end
|
36
|
+
|
37
|
+
duplicator = described_class.new('s1', 's2')
|
38
|
+
duplicator.perform!
|
39
|
+
|
40
|
+
Storey.switch("s2") do
|
41
|
+
expect(ActiveRecord::SchemaMigration.count).to eq s1_versions_count
|
42
|
+
end
|
43
|
+
end
|
30
44
|
end
|
31
45
|
|
32
46
|
end
|