storey 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/lib/storey/duplicator.rb +5 -5
- data/lib/storey/hstore.rb +2 -2
- data/lib/storey/migrator.rb +12 -9
- data/lib/storey/resets_column_info.rb +21 -0
- data/lib/storey/ruby_dumper.rb +3 -3
- data/lib/storey/sql_dumper.rb +3 -3
- data/lib/storey/version.rb +1 -1
- data/lib/storey.rb +16 -8
- data/lib/tasks/storey.rake +3 -1
- data/spec/dummy/config/initializers/migrations_path.rb +2 -0
- data/spec/migrator_spec.rb +25 -11
- data/spec/spec_helper.rb +6 -15
- data/spec/storey/create_spec.rb +4 -4
- data/spec/storey/duplicate_spec.rb +4 -4
- data/spec/storey/hstore_spec.rb +1 -1
- data/spec/tasks/storey_rake_spec.rb +10 -0
- data/storey.gemspec +1 -0
- metadata +97 -32
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae5569721f64878b097e1b98b07c035fb36a9d71
|
4
|
+
data.tar.gz: 4dca637ae254650c11a1140143b3242923eb015c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e62da00edaffe209439f36791dca9709cd9442b3c44a4046071cb7331ed6d0cf2bd3d4cf859da83b6c367673141dd635f558f36eb47ad5f2edb1f8384015a613
|
7
|
+
data.tar.gz: 2e5ae11654ed101a414c955e00d71cfd3e79c3341509c6a9b1b17c536d79da84c4cdfcb5f494a1161b8bb20827eb31c659f53822296e00c5b94d60031d8c6d14
|
data/CHANGELOG.md
ADDED
data/lib/storey/duplicator.rb
CHANGED
@@ -36,7 +36,7 @@ module Storey
|
|
36
36
|
|
37
37
|
def perform!
|
38
38
|
dump_schema
|
39
|
-
|
39
|
+
replace_occurrences
|
40
40
|
load_schema
|
41
41
|
end
|
42
42
|
|
@@ -92,7 +92,7 @@ module Storey
|
|
92
92
|
source_schema_migrations.each do |version|
|
93
93
|
unless target_schema_migrations.include?(version)
|
94
94
|
command = "INSERT INTO schema_migrations (version) VALUES ('#{version}');"
|
95
|
-
ActiveRecord::Base.connection.execute command
|
95
|
+
::ActiveRecord::Base.connection.execute command
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
@@ -100,17 +100,17 @@ module Storey
|
|
100
100
|
|
101
101
|
def source_schema_migrations
|
102
102
|
::Storey.switch(self.source_schema) do
|
103
|
-
ActiveRecord::Migrator.get_all_versions
|
103
|
+
::ActiveRecord::Migrator.get_all_versions
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
107
107
|
def target_schema_migrations
|
108
108
|
::Storey.switch(self.target_schema) do
|
109
|
-
ActiveRecord::Migrator.get_all_versions
|
109
|
+
::ActiveRecord::Migrator.get_all_versions
|
110
110
|
end
|
111
111
|
end
|
112
112
|
|
113
|
-
def
|
113
|
+
def replace_occurrences
|
114
114
|
File.open(self.source_file, 'r') do |file|
|
115
115
|
file.each_line do |line|
|
116
116
|
new_line = line.gsub(/#{self.source_schema}/, self.target_schema)
|
data/lib/storey/hstore.rb
CHANGED
@@ -8,8 +8,8 @@ module Storey
|
|
8
8
|
def install
|
9
9
|
ensure_hstore_is_persistent
|
10
10
|
Storey.create 'hstore', force: true
|
11
|
-
ActiveRecord::Base.connection.execute "CREATE EXTENSION IF NOT EXISTS hstore SCHEMA #{suffixify('hstore')}"
|
12
|
-
rescue ActiveRecord::StatementInvalid => e
|
11
|
+
::ActiveRecord::Base.connection.execute "CREATE EXTENSION IF NOT EXISTS hstore SCHEMA #{suffixify('hstore')}"
|
12
|
+
rescue ::ActiveRecord::StatementInvalid => e
|
13
13
|
if e.message =~ /could not open extension control file/
|
14
14
|
fail StoreyError, "Oops! Looks like the Hstore extension is not installed. Please install it for your OS first."
|
15
15
|
end
|
data/lib/storey/migrator.rb
CHANGED
@@ -3,25 +3,28 @@ module Storey
|
|
3
3
|
|
4
4
|
extend self
|
5
5
|
|
6
|
-
def migrate_all
|
7
|
-
|
6
|
+
def migrate_all(options={})
|
7
|
+
options[:version] = options[:version].to_i if options[:version]
|
8
|
+
self.migrate 'public', options
|
8
9
|
Dumper.dump
|
9
10
|
Storey.schemas(public: false).each do |schema|
|
10
|
-
self.migrate schema
|
11
|
+
self.migrate schema, options
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
14
|
-
def migrate(schema)
|
15
|
+
def migrate(schema, options={})
|
15
16
|
Storey.switch schema do
|
16
|
-
|
17
|
+
puts "= Migrating #{schema}"
|
18
|
+
::ActiveRecord::Migrator.migrate(::ActiveRecord::Migrator.migrations_path,
|
19
|
+
options[:version])
|
17
20
|
end
|
18
21
|
end
|
19
22
|
|
20
23
|
def run(direction, schema, version)
|
21
24
|
Storey.switch schema do
|
22
|
-
ActiveRecord::Migrator.run(
|
25
|
+
::ActiveRecord::Migrator.run(
|
23
26
|
direction,
|
24
|
-
ActiveRecord::Migrator.migrations_path,
|
27
|
+
::ActiveRecord::Migrator.migrations_path,
|
25
28
|
version
|
26
29
|
)
|
27
30
|
end
|
@@ -37,8 +40,8 @@ module Storey
|
|
37
40
|
def rollback(schema, step=1)
|
38
41
|
Storey.switch schema do
|
39
42
|
puts "= Rolling back `#{schema}` #{step} steps"
|
40
|
-
ActiveRecord::Migrator.rollback(
|
41
|
-
ActiveRecord::Migrator.migrations_path,
|
43
|
+
::ActiveRecord::Migrator.rollback(
|
44
|
+
::ActiveRecord::Migrator.migrations_path,
|
42
45
|
step
|
43
46
|
)
|
44
47
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Storey
|
2
|
+
class ResetsColumnInfo
|
3
|
+
|
4
|
+
easy_class_to_instance
|
5
|
+
|
6
|
+
def execute
|
7
|
+
descendants.each do |descendant|
|
8
|
+
descendant.reset_column_information
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def descendants
|
15
|
+
@descendants ||= ObjectSpace.each_object(Class).select do |klass|
|
16
|
+
klass < ActiveRecord::Base
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/storey/ruby_dumper.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'active_record/schema_dumper'
|
2
2
|
|
3
3
|
module Storey
|
4
|
-
|
4
|
+
class RubyDumper
|
5
5
|
|
6
6
|
def self.dump(*args)
|
7
7
|
self.new(*args).dump
|
@@ -14,8 +14,8 @@ module Storey
|
|
14
14
|
|
15
15
|
def dump
|
16
16
|
File.open(@file, "w:utf-8") do |file|
|
17
|
-
ActiveRecord::Base.establish_connection(Rails.env)
|
18
|
-
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
|
17
|
+
::ActiveRecord::Base.establish_connection(Rails.env)
|
18
|
+
::ActiveRecord::SchemaDumper.dump(::ActiveRecord::Base.connection, file)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/lib/storey/sql_dumper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Storey
|
2
|
-
|
2
|
+
class SqlDumper
|
3
3
|
|
4
4
|
def self.dump(*args)
|
5
5
|
self.new(*args).dump
|
@@ -10,7 +10,7 @@ module Storey
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def dump
|
13
|
-
abcs = ActiveRecord::Base.configurations
|
13
|
+
abcs = ::ActiveRecord::Base.configurations
|
14
14
|
set_psql_env(abcs[Rails.env])
|
15
15
|
search_path = abcs[Rails.env]['schema_search_path']
|
16
16
|
unless search_path.blank?
|
@@ -18,7 +18,7 @@ module Storey
|
|
18
18
|
end
|
19
19
|
`pg_dump -i -s -x -O -f #{Shellwords.escape(@file)} #{search_path} #{Shellwords.escape(abcs[Rails.env]['database'])}`
|
20
20
|
raise 'Error dumping database' if $?.exitstatus == 1
|
21
|
-
File.open(@file, "a") { |f| f << "SET search_path TO #{ActiveRecord::Base.connection.schema_search_path};\n\n" }
|
21
|
+
File.open(@file, "a") { |f| f << "SET search_path TO #{::ActiveRecord::Base.connection.schema_search_path};\n\n" }
|
22
22
|
end
|
23
23
|
|
24
24
|
end
|
data/lib/storey/version.rb
CHANGED
data/lib/storey.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "storey/version"
|
2
2
|
require "rails/all"
|
3
3
|
require "active_support/core_ext/module" # so we can use mattr_accessor
|
4
|
+
require 'easy_class_to_instance_method'
|
4
5
|
require 'storey/railtie' if defined?(Rails)
|
5
6
|
require 'storey/exceptions'
|
6
7
|
require 'storey/migrator'
|
@@ -12,6 +13,7 @@ require 'storey/sql_dumper'
|
|
12
13
|
require 'storey/native_schema_matcher'
|
13
14
|
require 'storey/suffixifier'
|
14
15
|
require 'storey/unsuffixifier'
|
16
|
+
require 'storey/resets_column_info'
|
15
17
|
|
16
18
|
module Storey
|
17
19
|
RESERVED_SCHEMAS = %w(hstore)
|
@@ -48,7 +50,7 @@ module Storey
|
|
48
50
|
def schema(options={})
|
49
51
|
options[:suffix] ||= false
|
50
52
|
|
51
|
-
name = ActiveRecord::Base.connection.schema_search_path
|
53
|
+
name = ::ActiveRecord::Base.connection.schema_search_path
|
52
54
|
|
53
55
|
if options[:suffix]
|
54
56
|
name
|
@@ -116,7 +118,7 @@ module Storey
|
|
116
118
|
sql << " AND nspname != 'information_schema'"
|
117
119
|
sql << " AND nspname != 'public'" unless options[:public]
|
118
120
|
|
119
|
-
names = ActiveRecord::Base.connection.query(sql).flatten
|
121
|
+
names = ::ActiveRecord::Base.connection.query(sql).flatten
|
120
122
|
|
121
123
|
if options[:suffix]
|
122
124
|
names
|
@@ -128,8 +130,8 @@ module Storey
|
|
128
130
|
def drop(name)
|
129
131
|
name = suffixify name
|
130
132
|
command = "DROP SCHEMA #{name} CASCADE"
|
131
|
-
ActiveRecord::Base.connection.execute(command)
|
132
|
-
rescue ActiveRecord::StatementInvalid => e
|
133
|
+
::ActiveRecord::Base.connection.execute(command)
|
134
|
+
rescue ::ActiveRecord::StatementInvalid => e
|
133
135
|
raise(Storey::SchemaNotFound,
|
134
136
|
%{The schema "#{name}" cannot be found. Error: #{e}})
|
135
137
|
end
|
@@ -149,9 +151,9 @@ module Storey
|
|
149
151
|
fail(Storey::SchemaNotFound, %{The schema "#{path}" cannot be found.})
|
150
152
|
end
|
151
153
|
|
152
|
-
ActiveRecord::Base.connection.schema_search_path = path
|
154
|
+
::ActiveRecord::Base.connection.schema_search_path = path
|
153
155
|
end
|
154
|
-
rescue ActiveRecord::StatementInvalid => e
|
156
|
+
rescue ::ActiveRecord::StatementInvalid => e
|
155
157
|
if e.to_s =~ /relation ".*" does not exist at character \d+/
|
156
158
|
warn "See https://github.com/ramontayag/storey/issues/11"
|
157
159
|
raise e
|
@@ -209,12 +211,12 @@ module Storey
|
|
209
211
|
protected
|
210
212
|
|
211
213
|
def schema_migrations
|
212
|
-
ActiveRecord::Migrator.get_all_versions
|
214
|
+
::ActiveRecord::Migrator.get_all_versions
|
213
215
|
end
|
214
216
|
|
215
217
|
def reset
|
216
218
|
path = self.schema_search_path_for(self.default_search_path)
|
217
|
-
ActiveRecord::Base.connection.schema_search_path = path
|
219
|
+
::ActiveRecord::Base.connection.schema_search_path = path
|
218
220
|
end
|
219
221
|
|
220
222
|
def process_excluded_models
|
@@ -240,4 +242,10 @@ module Storey
|
|
240
242
|
Unsuffixifier.unsuffixify schema_name
|
241
243
|
end
|
242
244
|
|
245
|
+
def reset_column_information
|
246
|
+
::ActiveRecord::Base.descendants.each do |descendant|
|
247
|
+
descendant.reset_column_information
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
243
251
|
end
|
data/lib/tasks/storey.rake
CHANGED
@@ -9,7 +9,9 @@ namespace :storey do
|
|
9
9
|
|
10
10
|
desc "Migrate all schemas including public"
|
11
11
|
task migrate: :environment do
|
12
|
-
|
12
|
+
options = {}
|
13
|
+
options[:version] = ENV['VERSION']
|
14
|
+
Storey::Migrator.migrate_all options
|
13
15
|
end
|
14
16
|
|
15
17
|
desc "Rolls the schema back to the previous version (specify steps w/ STEP=n) across all schemas."
|
data/spec/migrator_spec.rb
CHANGED
@@ -2,18 +2,24 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Storey::Migrator do
|
4
4
|
before do
|
5
|
-
@original_schema = ActiveRecord::Base.connection.schema_search_path
|
5
|
+
@original_schema = ::ActiveRecord::Base.connection.schema_search_path
|
6
6
|
@schema_1 = "first_schema"
|
7
7
|
Storey.create @schema_1
|
8
8
|
end
|
9
9
|
|
10
10
|
describe '.migrate_all' do
|
11
11
|
it 'should migrate the default search path first, then all available schemas' do
|
12
|
-
described_class.should_receive(:migrate).with('public').ordered
|
13
|
-
described_class.should_receive(:migrate).with(@schema_1).ordered
|
12
|
+
described_class.should_receive(:migrate).with('public', {}).ordered
|
13
|
+
described_class.should_receive(:migrate).with(@schema_1, {}).ordered
|
14
14
|
described_class.migrate_all
|
15
15
|
end
|
16
16
|
|
17
|
+
it 'should convert the version given to an integer' do
|
18
|
+
described_class.should_receive(:migrate).with('public', {version: 292})
|
19
|
+
described_class.should_receive(:migrate).with(@schema_1, {version: 292})
|
20
|
+
described_class.migrate_all version: '292'
|
21
|
+
end
|
22
|
+
|
17
23
|
it 'should dump the database' do
|
18
24
|
Storey::Dumper.should_receive(:dump)
|
19
25
|
described_class.migrate_all
|
@@ -23,8 +29,10 @@ describe Storey::Migrator do
|
|
23
29
|
describe '.migrate' do
|
24
30
|
context 'given a schema' do
|
25
31
|
it 'should connect to new db, then reset when done' do
|
26
|
-
ActiveRecord::Base.connection.should_receive(:schema_search_path=).
|
27
|
-
|
32
|
+
::ActiveRecord::Base.connection.should_receive(:schema_search_path=).
|
33
|
+
with(@schema_1).once
|
34
|
+
::ActiveRecord::Base.connection.should_receive(:schema_search_path=).
|
35
|
+
with(@original_schema).once
|
28
36
|
Storey::Migrator.migrate(@schema_1)
|
29
37
|
end
|
30
38
|
|
@@ -43,26 +51,32 @@ describe Storey::Migrator do
|
|
43
51
|
|
44
52
|
context "up" do
|
45
53
|
it "should connect to new db, then reset when done" do
|
46
|
-
ActiveRecord::Base.connection.should_receive(:schema_search_path=).
|
47
|
-
|
54
|
+
::ActiveRecord::Base.connection.should_receive(:schema_search_path=).
|
55
|
+
with(@schema_1).once
|
56
|
+
::ActiveRecord::Base.connection.should_receive(:schema_search_path=).
|
57
|
+
with(@original_schema).once
|
48
58
|
Storey::Migrator.run(:up, @schema_1, @migration_version_2)
|
49
59
|
end
|
50
60
|
|
51
61
|
it "should migrate to a version" do
|
52
|
-
ActiveRecord::Migrator.should_receive(:run).
|
62
|
+
ActiveRecord::Migrator.should_receive(:run).
|
63
|
+
with(:up, anything, @migration_version_1)
|
53
64
|
Storey::Migrator.run(:up, @schema_1, @migration_version_1)
|
54
65
|
end
|
55
66
|
end
|
56
67
|
|
57
68
|
describe "down" do
|
58
69
|
it "should connect to new db, then reset when done" do
|
59
|
-
ActiveRecord::Base.connection.should_receive(:schema_search_path=).
|
60
|
-
|
70
|
+
::ActiveRecord::Base.connection.should_receive(:schema_search_path=).
|
71
|
+
with(@schema_1).once
|
72
|
+
::ActiveRecord::Base.connection.should_receive(:schema_search_path=).
|
73
|
+
with(@original_schema).once
|
61
74
|
Storey::Migrator.run(:down, @schema_1, @migration_version_2)
|
62
75
|
end
|
63
76
|
|
64
77
|
it "should migrate to a version" do
|
65
|
-
ActiveRecord::Migrator.should_receive(:run).
|
78
|
+
ActiveRecord::Migrator.should_receive(:run).
|
79
|
+
with(:down, anything, @migration_version_1)
|
66
80
|
Storey::Migrator.run(:down, @schema_1, @migration_version_1)
|
67
81
|
end
|
68
82
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,23 +12,21 @@ require 'rake'
|
|
12
12
|
require 'pry'
|
13
13
|
|
14
14
|
RSpec.configure do |config|
|
15
|
-
config.
|
15
|
+
config.order = 'random'
|
16
|
+
|
17
|
+
config.before(:each) do
|
18
|
+
# We don't want configuration to leak into other tests
|
16
19
|
Storey.reload_config!
|
17
20
|
|
18
21
|
# Clean the public schema
|
19
22
|
Storey.switch do
|
20
|
-
tables = ActiveRecord::Base.connection.tables
|
23
|
+
tables = ::ActiveRecord::Base.connection.tables
|
21
24
|
# Don't invoke DatabaseCleaner if there are no tables,
|
22
25
|
# since that library chokes and tries to drop tables without names
|
23
26
|
if tables.size != 1 || tables[0] != 'schema_migrations'
|
24
27
|
DatabaseCleaner.clean_with :truncation
|
25
28
|
end
|
26
29
|
end
|
27
|
-
end
|
28
|
-
|
29
|
-
config.before(:each) do
|
30
|
-
# We don't want configuration to leak into other tests
|
31
|
-
Storey.reload_config!
|
32
30
|
|
33
31
|
# Always switch back to the default search path
|
34
32
|
# Some tests that didn't switch back broke the following tests
|
@@ -45,16 +43,9 @@ RSpec.configure do |config|
|
|
45
43
|
Rake.application = @rake
|
46
44
|
Dummy::Application.load_tasks
|
47
45
|
|
48
|
-
# It seems when instantiating our own rake object, misc.rake
|
49
|
-
# isn't loaded. We get the following error if we don't load misc.rake:
|
50
|
-
# RuntimeError: Don't know how to build task 'rails_env'
|
51
|
-
load "rails/tasks/misc.rake"
|
52
|
-
|
53
|
-
# we don't want any test that has set this to keep it hanging around
|
54
|
-
# screwing with our migration
|
55
46
|
ENV['STEP'] = ENV['VERSION'] = nil
|
56
47
|
Rails.application.config.active_record.schema_format = :ruby
|
57
|
-
|
48
|
+
Storey::Migrator.migrate_all
|
58
49
|
end
|
59
50
|
end
|
60
51
|
|
data/spec/storey/create_spec.rb
CHANGED
@@ -2,16 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Storey, "#create" do
|
4
4
|
it "should load the database structure into the new schema" do
|
5
|
-
public_tables = Storey.switch { ActiveRecord::Base.connection.tables }.sort
|
5
|
+
public_tables = Storey.switch { ::ActiveRecord::Base.connection.tables }.sort
|
6
6
|
Storey.create "foobar" do
|
7
|
-
foobar_tables = ActiveRecord::Base.connection.tables.sort
|
7
|
+
foobar_tables = ::ActiveRecord::Base.connection.tables.sort
|
8
8
|
foobar_tables.should == public_tables
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
context 'when in a database transaction and loading the database structure' do
|
13
13
|
it 'should not blow up and continue to create the schema' do
|
14
|
-
ActiveRecord::Base.transaction do
|
14
|
+
::ActiveRecord::Base.transaction do
|
15
15
|
Storey.create 'foobar'
|
16
16
|
end
|
17
17
|
Storey.schemas.should include('foobar')
|
@@ -29,7 +29,7 @@ describe Storey, "#create" do
|
|
29
29
|
context "when load_database_schema: false" do
|
30
30
|
it "should not load the structure" do
|
31
31
|
Storey.create "foobar", load_database_structure: false do
|
32
|
-
tables = ActiveRecord::Base.connection.tables
|
32
|
+
tables = ::ActiveRecord::Base.connection.tables
|
33
33
|
tables.should_not include('companies')
|
34
34
|
tables.should_not include('posts')
|
35
35
|
end
|
@@ -23,9 +23,9 @@ describe Storey, "#duplicate!" do
|
|
23
23
|
|
24
24
|
it "should create a schema with the same data under a new name" do
|
25
25
|
Storey.duplicate! 'ricky', 'bobby'
|
26
|
-
Storey.schemas.
|
26
|
+
expect(Storey.schemas).to include('bobby')
|
27
27
|
Storey.switch 'bobby' do
|
28
|
-
Post.count.
|
28
|
+
expect(Post.count).to eq(1)
|
29
29
|
Post.find_by_name("Hi").should_not be_nil
|
30
30
|
end
|
31
31
|
end
|
@@ -36,9 +36,9 @@ describe Storey, "#duplicate!" do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'should create a duplicate schema but copy the structure only' do
|
39
|
-
Storey.schemas.
|
39
|
+
expect(Storey.schemas).to include('bobby')
|
40
40
|
Storey.switch 'bobby' do
|
41
|
-
Post.count.
|
41
|
+
expect(Post.count).to eq(0)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
data/spec/storey/hstore_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe Storey::Hstore do
|
|
5
5
|
it 'should install the extension into the hstore schema' do
|
6
6
|
Storey.persistent_schemas = %w(hstore)
|
7
7
|
described_class.install
|
8
|
-
expect { ActiveRecord::Base.connection.execute "DROP EXTENSION hstore" }.
|
8
|
+
expect { ::ActiveRecord::Base.connection.execute "DROP EXTENSION hstore" }.
|
9
9
|
to_not raise_error(ActiveRecord::StatementInvalid)
|
10
10
|
end
|
11
11
|
|
@@ -23,6 +23,16 @@ describe Storey, "rake tasks" do
|
|
23
23
|
ActiveRecord::Migrator.should_receive(:migrate).exactly(@number_of_dbs + 1).times
|
24
24
|
@rake["storey:migrate"].invoke
|
25
25
|
end
|
26
|
+
|
27
|
+
context 'when a version is given' do
|
28
|
+
it 'should migrate to the given version' do
|
29
|
+
ENV['VERSION'] = '3299329'
|
30
|
+
ActiveRecord::Migrator.should_receive(:migrate).
|
31
|
+
with(ActiveRecord::Migrator.migrations_path, 3299329).
|
32
|
+
exactly(@number_of_dbs + 1).times
|
33
|
+
@rake["storey:migrate"].invoke
|
34
|
+
end
|
35
|
+
end
|
26
36
|
end
|
27
37
|
|
28
38
|
describe "storey:migrate:up" do
|
data/storey.gemspec
CHANGED
@@ -23,5 +23,6 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_development_dependency "pg", "~> 0.12.2"
|
24
24
|
s.add_development_dependency "database_cleaner"
|
25
25
|
s.add_development_dependency "pry"
|
26
|
+
s.add_runtime_dependency 'easy_class_to_instance_method', '~> 0.0.1'
|
26
27
|
s.add_runtime_dependency "rails", "~> 3.2.2"
|
27
28
|
end
|
metadata
CHANGED
@@ -1,36 +1,32 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ramon Tayag
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-06-12 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec-rails
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: pg
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,39 +41,48 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: database_cleaner
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: pry
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: easy_class_to_instance_method
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.0.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.1
|
78
83
|
- !ruby/object:Gem::Dependency
|
79
84
|
name: rails
|
80
85
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
86
|
requirements:
|
83
87
|
- - ~>
|
84
88
|
- !ruby/object:Gem::Version
|
@@ -86,7 +90,6 @@ dependencies:
|
|
86
90
|
type: :runtime
|
87
91
|
prerelease: false
|
88
92
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
93
|
requirements:
|
91
94
|
- - ~>
|
92
95
|
- !ruby/object:Gem::Version
|
@@ -101,6 +104,7 @@ extra_rdoc_files: []
|
|
101
104
|
files:
|
102
105
|
- .gitignore
|
103
106
|
- .rspec
|
107
|
+
- CHANGELOG.md
|
104
108
|
- Gemfile
|
105
109
|
- README.md
|
106
110
|
- Rakefile
|
@@ -112,6 +116,7 @@ files:
|
|
112
116
|
- lib/storey/migrator.rb
|
113
117
|
- lib/storey/native_schema_matcher.rb
|
114
118
|
- lib/storey/railtie.rb
|
119
|
+
- lib/storey/resets_column_info.rb
|
115
120
|
- lib/storey/ruby_dumper.rb
|
116
121
|
- lib/storey/sql_dumper.rb
|
117
122
|
- lib/storey/suffixifier.rb
|
@@ -141,6 +146,7 @@ files:
|
|
141
146
|
- spec/dummy/config/environments/test.rb
|
142
147
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
143
148
|
- spec/dummy/config/initializers/inflections.rb
|
149
|
+
- spec/dummy/config/initializers/migrations_path.rb
|
144
150
|
- spec/dummy/config/initializers/mime_types.rb
|
145
151
|
- spec/dummy/config/initializers/secret_token.rb
|
146
152
|
- spec/dummy/config/initializers/session_store.rb
|
@@ -187,32 +193,91 @@ files:
|
|
187
193
|
- storey.gemspec
|
188
194
|
homepage: https://github.com/ramontayag/storey
|
189
195
|
licenses: []
|
196
|
+
metadata: {}
|
190
197
|
post_install_message:
|
191
198
|
rdoc_options: []
|
192
199
|
require_paths:
|
193
200
|
- lib
|
194
201
|
required_ruby_version: !ruby/object:Gem::Requirement
|
195
|
-
none: false
|
196
202
|
requirements:
|
197
|
-
- -
|
203
|
+
- - '>='
|
198
204
|
- !ruby/object:Gem::Version
|
199
205
|
version: '0'
|
200
|
-
segments:
|
201
|
-
- 0
|
202
|
-
hash: 1554154607789373813
|
203
206
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
|
-
none: false
|
205
207
|
requirements:
|
206
|
-
- -
|
208
|
+
- - '>='
|
207
209
|
- !ruby/object:Gem::Version
|
208
210
|
version: '0'
|
209
|
-
segments:
|
210
|
-
- 0
|
211
|
-
hash: 1554154607789373813
|
212
211
|
requirements: []
|
213
212
|
rubyforge_project: storey
|
214
|
-
rubygems_version:
|
213
|
+
rubygems_version: 2.0.3
|
215
214
|
signing_key:
|
216
|
-
specification_version:
|
215
|
+
specification_version: 4
|
217
216
|
summary: Manage multiple PostgreSQL schemas in your multi-tenant app.
|
218
|
-
test_files:
|
217
|
+
test_files:
|
218
|
+
- spec/config/database.yml.sample
|
219
|
+
- spec/dummy/Rakefile
|
220
|
+
- spec/dummy/app/assets/javascripts/application.js
|
221
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
222
|
+
- spec/dummy/app/controllers/application_controller.rb
|
223
|
+
- spec/dummy/app/helpers/application_helper.rb
|
224
|
+
- spec/dummy/app/mailers/.gitkeep
|
225
|
+
- spec/dummy/app/models/.gitkeep
|
226
|
+
- spec/dummy/app/models/company.rb
|
227
|
+
- spec/dummy/app/models/fake.rb
|
228
|
+
- spec/dummy/app/models/post.rb
|
229
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
230
|
+
- spec/dummy/config.ru
|
231
|
+
- spec/dummy/config/application.rb
|
232
|
+
- spec/dummy/config/boot.rb
|
233
|
+
- spec/dummy/config/database.yml.sample
|
234
|
+
- spec/dummy/config/environment.rb
|
235
|
+
- spec/dummy/config/environments/development.rb
|
236
|
+
- spec/dummy/config/environments/production.rb
|
237
|
+
- spec/dummy/config/environments/test.rb
|
238
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
239
|
+
- spec/dummy/config/initializers/inflections.rb
|
240
|
+
- spec/dummy/config/initializers/migrations_path.rb
|
241
|
+
- spec/dummy/config/initializers/mime_types.rb
|
242
|
+
- spec/dummy/config/initializers/secret_token.rb
|
243
|
+
- spec/dummy/config/initializers/session_store.rb
|
244
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
245
|
+
- spec/dummy/config/locales/en.yml
|
246
|
+
- spec/dummy/config/routes.rb
|
247
|
+
- spec/dummy/db/migrate/20120115060713_create_companies.rb
|
248
|
+
- spec/dummy/db/migrate/20120115060728_create_posts.rb
|
249
|
+
- spec/dummy/db/schema.rb
|
250
|
+
- spec/dummy/lib/assets/.gitkeep
|
251
|
+
- spec/dummy/log/.gitkeep
|
252
|
+
- spec/dummy/public/404.html
|
253
|
+
- spec/dummy/public/422.html
|
254
|
+
- spec/dummy/public/500.html
|
255
|
+
- spec/dummy/public/favicon.ico
|
256
|
+
- spec/dummy/script/rails
|
257
|
+
- spec/fixtures/.gitkeep
|
258
|
+
- spec/migrator_spec.rb
|
259
|
+
- spec/spec_helper.rb
|
260
|
+
- spec/storey/command_line_switches_spec.rb
|
261
|
+
- spec/storey/configuration_spec.rb
|
262
|
+
- spec/storey/create_plain_schema_spec.rb
|
263
|
+
- spec/storey/create_spec.rb
|
264
|
+
- spec/storey/default_schema.rb
|
265
|
+
- spec/storey/default_search_path_spec.rb
|
266
|
+
- spec/storey/drop_spec.rb
|
267
|
+
- spec/storey/dumper_spec.rb
|
268
|
+
- spec/storey/duplicate_spec.rb
|
269
|
+
- spec/storey/duplicator_spec.rb
|
270
|
+
- spec/storey/excluded_models_spec.rb
|
271
|
+
- spec/storey/hstore_spec.rb
|
272
|
+
- spec/storey/native_schema_matcher_spec.rb
|
273
|
+
- spec/storey/persistent_schemas_spec.rb
|
274
|
+
- spec/storey/ruby_dumper_spec.rb
|
275
|
+
- spec/storey/schema_exists_spec.rb
|
276
|
+
- spec/storey/schema_search_path_for_spec.rb
|
277
|
+
- spec/storey/schema_spec.rb
|
278
|
+
- spec/storey/schemas_spec.rb
|
279
|
+
- spec/storey/sql_dumper_spec.rb
|
280
|
+
- spec/storey/suffixifier_spec.rb
|
281
|
+
- spec/storey/switch_spec.rb
|
282
|
+
- spec/storey/unsuffixifier_spec.rb
|
283
|
+
- spec/tasks/storey_rake_spec.rb
|