storey 0.3.4 → 0.3.5
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.
- data/Gemfile +2 -0
- data/lib/storey/dumper.rb +16 -30
- data/lib/storey/migrator.rb +7 -0
- data/lib/storey/ruby_dumper.rb +21 -0
- data/lib/storey/sql_dumper.rb +23 -0
- data/lib/storey/version.rb +1 -1
- data/lib/storey.rb +40 -19
- data/lib/tasks/storey.rake +1 -5
- data/spec/dummy/db/schema.rb +1 -11
- data/spec/migrator_spec.rb +11 -0
- data/spec/storey/drop_spec.rb +2 -3
- data/spec/storey/dumper_spec.rb +90 -38
- data/spec/storey/ruby_dumper_spec.rb +27 -0
- data/spec/storey/sql_dumper_spec.rb +26 -0
- data/spec/storey/switch_spec.rb +12 -0
- data/spec/tasks/storey_rake_spec.rb +4 -11
- metadata +10 -6
- data/spec/dummy/log/development.log +0 -0
data/Gemfile
CHANGED
data/lib/storey/dumper.rb
CHANGED
@@ -1,39 +1,25 @@
|
|
1
1
|
class Storey::Dumper
|
2
|
-
def self.dump(options={})
|
3
|
-
case Rails.configuration.active_record.schema_format
|
4
|
-
when :sql ; self.dump_structure_sql(options)
|
5
|
-
when :ruby ; self.dump_schema_rb(options)
|
6
|
-
end
|
7
|
-
end
|
8
2
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
ActiveRecord::Base.establish_connection(Rails.env)
|
14
|
-
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
|
15
|
-
end
|
3
|
+
delegate :dump, to: :dumper
|
4
|
+
|
5
|
+
def self.dump(*args)
|
6
|
+
self.new(*args).dump
|
16
7
|
end
|
17
8
|
|
18
|
-
def
|
19
|
-
|
20
|
-
filename = options[:file] || File.join(Rails.root, "db", "structure.sql")
|
21
|
-
set_psql_env(abcs[Rails.env])
|
22
|
-
search_path = abcs[Rails.env]['schema_search_path']
|
23
|
-
unless search_path.blank?
|
24
|
-
search_path = search_path.split(",").map{|search_path_part| "--schema=#{Shellwords.escape(search_path_part.strip)}" }.join(" ")
|
25
|
-
end
|
26
|
-
`pg_dump -i -s -x -O -f #{Shellwords.escape(filename)} #{search_path} #{Shellwords.escape(abcs[Rails.env]['database'])}`
|
27
|
-
raise 'Error dumping database' if $?.exitstatus == 1
|
28
|
-
File.open(filename, "a") { |f| f << "SET search_path TO #{ActiveRecord::Base.connection.schema_search_path};\n\n" }
|
9
|
+
def initialize(options={})
|
10
|
+
@options = options
|
29
11
|
end
|
30
12
|
|
31
|
-
|
13
|
+
def dumper
|
14
|
+
dumper_class.new(@options)
|
15
|
+
end
|
32
16
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
17
|
+
def dumper_class
|
18
|
+
schema_format = Rails.configuration.active_record.schema_format || :ruby
|
19
|
+
klass = case schema_format
|
20
|
+
when :sql; Storey::SqlDumper
|
21
|
+
when :ruby; Storey::RubyDumper
|
22
|
+
end
|
38
23
|
end
|
24
|
+
|
39
25
|
end
|
data/lib/storey/migrator.rb
CHANGED
@@ -25,6 +25,13 @@ module Storey::Migrator
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def rollback_all(step=1)
|
29
|
+
Storey.schemas.each do |schema_name|
|
30
|
+
puts "rolling back #{schema_name}"
|
31
|
+
self.rollback(schema_name, step)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
28
35
|
def rollback(schema, step=1)
|
29
36
|
Storey.switch schema do
|
30
37
|
ActiveRecord::Migrator.rollback(
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'active_record/schema_dumper'
|
2
|
+
|
3
|
+
class Storey::RubyDumper
|
4
|
+
|
5
|
+
def self.dump(*args)
|
6
|
+
self.new(*args).dump
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(options={})
|
10
|
+
default_file_path = File.join(Rails.root, 'db', 'schema.rb')
|
11
|
+
@file = options[:file] || default_file_path
|
12
|
+
end
|
13
|
+
|
14
|
+
def dump
|
15
|
+
File.open(@file, "w:utf-8") do |file|
|
16
|
+
ActiveRecord::Base.establish_connection(Rails.env)
|
17
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Storey::SqlDumper
|
2
|
+
|
3
|
+
def self.dump(*args)
|
4
|
+
self.new(*args).dump
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize(options={})
|
8
|
+
@file = options[:file] || File.join(Rails.root, "db", "structure.sql")
|
9
|
+
end
|
10
|
+
|
11
|
+
def dump
|
12
|
+
abcs = ActiveRecord::Base.configurations
|
13
|
+
set_psql_env(abcs[Rails.env])
|
14
|
+
search_path = abcs[Rails.env]['schema_search_path']
|
15
|
+
unless search_path.blank?
|
16
|
+
search_path = search_path.split(",").map{|search_path_part| "--schema=#{Shellwords.escape(search_path_part.strip)}" }.join(" ")
|
17
|
+
end
|
18
|
+
`pg_dump -i -s -x -O -f #{Shellwords.escape(@file)} #{search_path} #{Shellwords.escape(abcs[Rails.env]['database'])}`
|
19
|
+
raise 'Error dumping database' if $?.exitstatus == 1
|
20
|
+
File.open(@file, "a") { |f| f << "SET search_path TO #{ActiveRecord::Base.connection.schema_search_path};\n\n" }
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/storey/version.rb
CHANGED
data/lib/storey.rb
CHANGED
@@ -7,6 +7,8 @@ require 'storey/migrator'
|
|
7
7
|
require 'storey/duplicator'
|
8
8
|
require 'storey/hstore'
|
9
9
|
require 'storey/dumper'
|
10
|
+
require 'storey/ruby_dumper'
|
11
|
+
require 'storey/sql_dumper'
|
10
12
|
|
11
13
|
module Storey
|
12
14
|
RESERVED_SCHEMAS = %w(hstore)
|
@@ -45,14 +47,27 @@ module Storey
|
|
45
47
|
end
|
46
48
|
|
47
49
|
def create(name, options={}, &block)
|
48
|
-
|
49
|
-
|
50
|
-
|
50
|
+
if name.blank?
|
51
|
+
fail ArgumentError, "Must pass in a valid schema name"
|
52
|
+
end
|
53
|
+
|
54
|
+
if RESERVED_SCHEMAS.include?(name) && !options[:force]
|
55
|
+
fail ArgumentError, "'#{name}' is a reserved schema name"
|
56
|
+
end
|
57
|
+
|
58
|
+
if self.schemas.include?(name)
|
59
|
+
fail(Storey::SchemaExists,
|
60
|
+
%{The schema "#{name}" already exists.})
|
61
|
+
end
|
51
62
|
|
52
|
-
|
63
|
+
if options[:load_database_structure].nil?
|
64
|
+
options[:load_database_structure] = true
|
65
|
+
end
|
53
66
|
|
54
67
|
if options[:load_database_structure]
|
55
|
-
duplicator = Storey::Duplicator.new
|
68
|
+
duplicator = Storey::Duplicator.new('public',
|
69
|
+
name,
|
70
|
+
structure_only: true)
|
56
71
|
duplicator.perform!
|
57
72
|
name = suffixify name
|
58
73
|
switch name do
|
@@ -64,13 +79,17 @@ module Storey
|
|
64
79
|
end
|
65
80
|
|
66
81
|
def create_plain_schema(schema_name)
|
67
|
-
|
82
|
+
name = self.suffixify schema_name
|
83
|
+
command = %{"CREATE SCHEMA #{name}"}
|
84
|
+
switches = self.command_line_switches(command: command)
|
68
85
|
`psql #{switches}`
|
69
86
|
end
|
70
87
|
|
71
88
|
def command_line_switches(options={})
|
72
89
|
switches = {}
|
73
|
-
|
90
|
+
if self.database_config.has_key?(:host)
|
91
|
+
switches[:host] = self.database_config[:host]
|
92
|
+
end
|
74
93
|
switches[:dbname] = self.database_config[:database]
|
75
94
|
switches[:username] = self.database_config[:username]
|
76
95
|
switches = switches.merge(options)
|
@@ -97,9 +116,11 @@ module Storey
|
|
97
116
|
|
98
117
|
def drop(name)
|
99
118
|
name = suffixify name
|
100
|
-
|
119
|
+
command = "DROP SCHEMA #{name} CASCADE"
|
120
|
+
ActiveRecord::Base.connection.execute(command)
|
101
121
|
rescue ActiveRecord::StatementInvalid => e
|
102
|
-
raise
|
122
|
+
raise(Storey::SchemaNotFound,
|
123
|
+
%{The schema "#{name}" cannot be found. Error: #{e}})
|
103
124
|
end
|
104
125
|
|
105
126
|
def switch(name=nil, &block)
|
@@ -110,11 +131,12 @@ module Storey
|
|
110
131
|
switch original_schema
|
111
132
|
result
|
112
133
|
else
|
113
|
-
reset and return if name.blank?
|
134
|
+
reset and return if name.blank? || name == 'public'
|
114
135
|
path = self.schema_search_path_for(name)
|
115
136
|
|
116
137
|
unless self.schema_exists?(name)
|
117
|
-
fail
|
138
|
+
fail(Storey::SchemaNotFound,
|
139
|
+
%{The schema "#{path}" cannot be found.})
|
118
140
|
end
|
119
141
|
|
120
142
|
ActiveRecord::Base.connection.schema_search_path = path
|
@@ -136,18 +158,15 @@ module Storey
|
|
136
158
|
schema_names = schema_name.split(',')
|
137
159
|
schemas_not_in_db = schema_names - schemas_in_db
|
138
160
|
schemas_not_in_db.empty?
|
139
|
-
# existence = schema_names.map do |s|
|
140
|
-
# schemas_in_db.include?(s)
|
141
|
-
# end
|
142
|
-
# return false if existence.include?(false)
|
143
|
-
# true
|
144
161
|
end
|
145
162
|
|
146
163
|
def schema_search_path_for(schema_name)
|
147
164
|
schema_names = schema_name.split(',')
|
148
165
|
path = [suffixify(schema_name)]
|
149
166
|
self.persistent_schemas.each do |schema|
|
150
|
-
|
167
|
+
unless schema_names.include?(schema)
|
168
|
+
path << suffixify(schema)
|
169
|
+
end
|
151
170
|
end
|
152
171
|
path.uniq.join(',')
|
153
172
|
end
|
@@ -159,11 +178,13 @@ module Storey
|
|
159
178
|
end
|
160
179
|
|
161
180
|
def database_config
|
162
|
-
Rails.configuration.
|
181
|
+
Rails.configuration.
|
182
|
+
database_configuration[Rails.env].
|
183
|
+
with_indifferent_access
|
163
184
|
end
|
164
185
|
|
165
186
|
def duplicate!(from_schema, to_schema, options={})
|
166
|
-
duplicator = Duplicator.new
|
187
|
+
duplicator = Duplicator.new(from_schema, to_schema, options)
|
167
188
|
duplicator.perform!
|
168
189
|
end
|
169
190
|
|
data/lib/tasks/storey.rake
CHANGED
@@ -15,11 +15,7 @@ namespace :storey do
|
|
15
15
|
desc "Rolls the schema back to the previous version (specify steps w/ STEP=n) across all schemas."
|
16
16
|
task :rollback => 'db:rollback' do
|
17
17
|
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
|
18
|
-
|
19
|
-
Storey.schemas.each do |db|
|
20
|
-
puts("Rolling back #{db} database")
|
21
|
-
Storey::Migrator.rollback db, step
|
22
|
-
end
|
18
|
+
Storey::Migrator.rollback_all(step)
|
23
19
|
end
|
24
20
|
|
25
21
|
namespace :migrate do
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,16 +11,6 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended to check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(:version =>
|
15
|
-
|
16
|
-
create_table "companies", :force => true do |t|
|
17
|
-
t.string "name"
|
18
|
-
t.string "schema_name"
|
19
|
-
end
|
20
|
-
|
21
|
-
create_table "posts", :force => true do |t|
|
22
|
-
t.string "name"
|
23
|
-
t.text "body"
|
24
|
-
end
|
14
|
+
ActiveRecord::Schema.define(:version => 0) do
|
25
15
|
|
26
16
|
end
|
data/spec/migrator_spec.rb
CHANGED
@@ -67,6 +67,17 @@ describe Storey::Migrator do
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
describe '.rollback_all' do
|
71
|
+
it 'should rollback all schemas exactly :steps times' do
|
72
|
+
steps = 2
|
73
|
+
['public', 'first_schema'].each do |schema|
|
74
|
+
described_class.should_receive(:rollback).
|
75
|
+
with(schema, steps).once
|
76
|
+
end
|
77
|
+
described_class.rollback_all(steps)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
70
81
|
describe "#rollback" do
|
71
82
|
it "should rollback the db" do
|
72
83
|
@steps = 2
|
data/spec/storey/drop_spec.rb
CHANGED
@@ -23,9 +23,8 @@ describe Storey, "#drop" do
|
|
23
23
|
|
24
24
|
context "when the schema does not exist" do
|
25
25
|
it "should raise an error" do
|
26
|
-
expect {
|
27
|
-
Storey
|
28
|
-
}.to raise_error(Storey::SchemaNotFound, %{The schema "foobar" cannot be found.})
|
26
|
+
expect { Storey.drop "foobar" }.
|
27
|
+
to raise_error(Storey::SchemaNotFound)
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
data/spec/storey/dumper_spec.rb
CHANGED
@@ -1,53 +1,105 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Storey::Dumper do
|
4
|
-
describe '.dump' do
|
5
|
-
context 'when the schema_format is :ruby' do
|
6
|
-
before do
|
7
|
-
Rails.configuration.active_record.schema_format = :ruby
|
8
|
-
end
|
9
4
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
5
|
+
describe '#dump' do
|
6
|
+
it 'should dump the schema using the correct dumper' do
|
7
|
+
special_dumper = double
|
8
|
+
args = {}
|
9
|
+
dumper = described_class.new(args)
|
10
|
+
dumper.stub(:dumper).and_return(special_dumper)
|
11
|
+
special_dumper.should_receive(:dump).once
|
12
|
+
dumper.dump
|
13
|
+
end
|
14
|
+
end
|
17
15
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
FileUtils.rm schema_rb_path if File.exists?(schema_rb_path)
|
25
|
-
end
|
26
|
-
end
|
16
|
+
describe '#dumper' do
|
17
|
+
it 'should be an instance of the dumper_class with the options passed through' do
|
18
|
+
options = {:a => 'b'}
|
19
|
+
dumper = described_class.new(options)
|
20
|
+
dumper.dumper_class.should_receive(:new).with(options).and_return('dumper')
|
21
|
+
dumper.dumper.should == 'dumper'
|
27
22
|
end
|
23
|
+
end
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
describe '#dumper_class' do
|
26
|
+
context 'when the schema_format is nil' do
|
27
|
+
it 'should be RubyDumper' do
|
28
|
+
Rails.configuration.active_record.schema_format = nil
|
29
|
+
described_class.new.dumper_class.should == Storey::RubyDumper
|
32
30
|
end
|
31
|
+
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
described_class.
|
38
|
-
File.should exist(structure_path)
|
39
|
-
FileUtils.rm structure_path
|
33
|
+
context 'when the schema_format is :ruby' do
|
34
|
+
it 'should be RubyDumper' do
|
35
|
+
Rails.configuration.active_record.schema_format = :ruby
|
36
|
+
described_class.new.dumper_class.should == Storey::RubyDumper
|
40
37
|
end
|
38
|
+
end
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
described_class.dump file: structure_path
|
47
|
-
File.should exist(structure_path)
|
48
|
-
FileUtils.rm structure_path
|
49
|
-
end
|
40
|
+
context 'when the schema_format is :sql' do
|
41
|
+
it 'should be RubyDumper' do
|
42
|
+
Rails.configuration.active_record.schema_format = :sql
|
43
|
+
described_class.new.dumper_class.should == Storey::SqlDumper
|
50
44
|
end
|
51
45
|
end
|
52
46
|
end
|
47
|
+
|
48
|
+
# describe '.dump' do
|
49
|
+
# context 'when schema_format is not set' do
|
50
|
+
# it 'should default to dumping ruby format' do
|
51
|
+
# Rails.configuration.active_record.schema_format = nil
|
52
|
+
# described_class.should_receive(:dump_schema_rb).once
|
53
|
+
# described_class.dump
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
|
57
|
+
# context 'when the schema_format is :ruby' do
|
58
|
+
# before do
|
59
|
+
# Rails.configuration.active_record.schema_format = :ruby
|
60
|
+
# end
|
61
|
+
|
62
|
+
# it 'should create a db/schema.rb file' do
|
63
|
+
# schema_rb_path = File.join Rails.root, 'db', 'schema.rb'
|
64
|
+
# FileUtils.rm schema_rb_path if File.exists?(schema_rb_path)
|
65
|
+
# described_class.dump
|
66
|
+
# File.should exist(schema_rb_path)
|
67
|
+
# FileUtils.rm schema_rb_path if File.exists?(schema_rb_path)
|
68
|
+
# end
|
69
|
+
|
70
|
+
# context 'given a file is specified' do
|
71
|
+
# it 'should create the schema dump file in the specified location' do
|
72
|
+
# schema_rb_path = File.join Rails.root, 'db', 'schema2.rb'
|
73
|
+
# FileUtils.rm schema_rb_path if File.exists?(schema_rb_path)
|
74
|
+
# described_class.dump file: schema_rb_path
|
75
|
+
# File.should exist(schema_rb_path)
|
76
|
+
# FileUtils.rm schema_rb_path if File.exists?(schema_rb_path)
|
77
|
+
# end
|
78
|
+
# end
|
79
|
+
# end
|
80
|
+
|
81
|
+
# context 'when the schema_format is :sql' do
|
82
|
+
# before do
|
83
|
+
# Rails.configuration.active_record.schema_format = :sql
|
84
|
+
# end
|
85
|
+
|
86
|
+
# it 'should create a db/structure.sql file' do
|
87
|
+
# structure_path = File.join Rails.root, 'db', 'structure.sql'
|
88
|
+
# FileUtils.rm structure_path if File.exists?(structure_path)
|
89
|
+
# described_class.dump
|
90
|
+
# File.should exist(structure_path)
|
91
|
+
# FileUtils.rm structure_path
|
92
|
+
# end
|
93
|
+
|
94
|
+
# context 'when the file is specified' do
|
95
|
+
# it 'should create dump into the given file' do
|
96
|
+
# structure_path = File.join Rails.root, 'db', 'structure2.sql'
|
97
|
+
# FileUtils.rm structure_path if File.exists?(structure_path)
|
98
|
+
# described_class.dump file: structure_path
|
99
|
+
# File.should exist(structure_path)
|
100
|
+
# FileUtils.rm structure_path
|
101
|
+
# end
|
102
|
+
# end
|
103
|
+
# end
|
104
|
+
# end
|
53
105
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Storey::RubyDumper do
|
4
|
+
|
5
|
+
describe '.dump' do
|
6
|
+
it 'should create a db/schema.rb file' do
|
7
|
+
schema_rb_path = File.join(Rails.root, 'db', 'schema.rb')
|
8
|
+
FileUtils.rm(schema_rb_path) if File.exists?(schema_rb_path)
|
9
|
+
dumper = described_class.new
|
10
|
+
dumper.dump
|
11
|
+
File.should exist(schema_rb_path)
|
12
|
+
FileUtils.rm(schema_rb_path) if File.exists?(schema_rb_path)
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'given a file is specified' do
|
16
|
+
it 'should create the schema dump file in the specified location' do
|
17
|
+
schema_rb_path = File.join(Rails.root, 'db', 'schema2.rb')
|
18
|
+
FileUtils.rm(schema_rb_path) if File.exists?(schema_rb_path)
|
19
|
+
dumper = described_class.new(file: schema_rb_path)
|
20
|
+
dumper.dump
|
21
|
+
File.should exist(schema_rb_path)
|
22
|
+
FileUtils.rm(schema_rb_path) if File.exists?(schema_rb_path)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Storey::SqlDumper do
|
4
|
+
|
5
|
+
describe '#dump' do
|
6
|
+
it 'should create a db/structure.sql file' do
|
7
|
+
structure_path = File.join(Rails.root, 'db', 'structure.sql')
|
8
|
+
FileUtils.rm(structure_path) if File.exists?(structure_path)
|
9
|
+
described_class.new.dump
|
10
|
+
File.should exist(structure_path)
|
11
|
+
FileUtils.rm(structure_path)
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when the file is specified' do
|
15
|
+
it 'should create dump into the given file' do
|
16
|
+
structure_path = File.join(Rails.root, 'db', 'structure2.sql')
|
17
|
+
FileUtils.rm(structure_path) if File.exists?(structure_path)
|
18
|
+
dumper = described_class.new(file: structure_path)
|
19
|
+
dumper.dump
|
20
|
+
File.should exist(structure_path)
|
21
|
+
FileUtils.rm structure_path
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/spec/storey/switch_spec.rb
CHANGED
@@ -159,4 +159,16 @@ describe Storey, "#switch" do
|
|
159
159
|
end
|
160
160
|
|
161
161
|
end
|
162
|
+
|
163
|
+
context 'when switching to the default/public schema' do
|
164
|
+
it 'should reset' do
|
165
|
+
Storey.create 'another'
|
166
|
+
Storey.switch 'another'
|
167
|
+
Storey.switch('public') do
|
168
|
+
Storey.schema.should == Storey.default_search_path
|
169
|
+
end
|
170
|
+
Storey.switch 'public'
|
171
|
+
Storey.schema.should == Storey.default_search_path
|
172
|
+
end
|
173
|
+
end
|
162
174
|
end
|
@@ -83,22 +83,15 @@ describe Storey, "rake tasks" do
|
|
83
83
|
end
|
84
84
|
|
85
85
|
describe "storey:rollback" do
|
86
|
-
before do
|
87
|
-
@step = 2
|
88
|
-
end
|
89
|
-
|
90
86
|
it "should rollback dbs" do
|
91
|
-
Storey::Migrator.should_receive(:
|
87
|
+
Storey::Migrator.should_receive(:rollback_all).once
|
92
88
|
@rake['storey:rollback'].invoke
|
93
89
|
end
|
94
90
|
|
95
91
|
it "should rollback dbs STEP amt" do
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
).exactly(@number_of_dbs+1).times
|
100
|
-
|
101
|
-
ENV['STEP'] = @step.to_s
|
92
|
+
step = 2
|
93
|
+
Storey::Migrator.should_receive(:rollback_all).with(step).once
|
94
|
+
ENV['STEP'] = step.to_s
|
102
95
|
@rake['storey:rollback'].invoke
|
103
96
|
end
|
104
97
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: storey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-rails
|
@@ -111,6 +111,8 @@ files:
|
|
111
111
|
- lib/storey/hstore.rb
|
112
112
|
- lib/storey/migrator.rb
|
113
113
|
- lib/storey/railtie.rb
|
114
|
+
- lib/storey/ruby_dumper.rb
|
115
|
+
- lib/storey/sql_dumper.rb
|
114
116
|
- lib/storey/version.rb
|
115
117
|
- lib/tasks/storey.rake
|
116
118
|
- rvmrc.sample
|
@@ -147,7 +149,6 @@ files:
|
|
147
149
|
- spec/dummy/db/schema.rb
|
148
150
|
- spec/dummy/lib/assets/.gitkeep
|
149
151
|
- spec/dummy/log/.gitkeep
|
150
|
-
- spec/dummy/log/development.log
|
151
152
|
- spec/dummy/public/404.html
|
152
153
|
- spec/dummy/public/422.html
|
153
154
|
- spec/dummy/public/500.html
|
@@ -167,10 +168,12 @@ files:
|
|
167
168
|
- spec/storey/excluded_models_spec.rb
|
168
169
|
- spec/storey/hstore_spec.rb
|
169
170
|
- spec/storey/persistent_schemas_spec.rb
|
171
|
+
- spec/storey/ruby_dumper_spec.rb
|
170
172
|
- spec/storey/schema_exists_spec.rb
|
171
173
|
- spec/storey/schema_search_path_for_spec.rb
|
172
174
|
- spec/storey/schema_spec.rb
|
173
175
|
- spec/storey/schemas_spec.rb
|
176
|
+
- spec/storey/sql_dumper_spec.rb
|
174
177
|
- spec/storey/suffixify_spec.rb
|
175
178
|
- spec/storey/switch_spec.rb
|
176
179
|
- spec/tasks/storey_rake_spec.rb
|
@@ -189,7 +192,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
189
192
|
version: '0'
|
190
193
|
segments:
|
191
194
|
- 0
|
192
|
-
hash: -
|
195
|
+
hash: -1594116376623390099
|
193
196
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
197
|
none: false
|
195
198
|
requirements:
|
@@ -198,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
201
|
version: '0'
|
199
202
|
segments:
|
200
203
|
- 0
|
201
|
-
hash: -
|
204
|
+
hash: -1594116376623390099
|
202
205
|
requirements: []
|
203
206
|
rubyforge_project: storey
|
204
207
|
rubygems_version: 1.8.24
|
@@ -239,7 +242,6 @@ test_files:
|
|
239
242
|
- spec/dummy/db/schema.rb
|
240
243
|
- spec/dummy/lib/assets/.gitkeep
|
241
244
|
- spec/dummy/log/.gitkeep
|
242
|
-
- spec/dummy/log/development.log
|
243
245
|
- spec/dummy/public/404.html
|
244
246
|
- spec/dummy/public/422.html
|
245
247
|
- spec/dummy/public/500.html
|
@@ -259,10 +261,12 @@ test_files:
|
|
259
261
|
- spec/storey/excluded_models_spec.rb
|
260
262
|
- spec/storey/hstore_spec.rb
|
261
263
|
- spec/storey/persistent_schemas_spec.rb
|
264
|
+
- spec/storey/ruby_dumper_spec.rb
|
262
265
|
- spec/storey/schema_exists_spec.rb
|
263
266
|
- spec/storey/schema_search_path_for_spec.rb
|
264
267
|
- spec/storey/schema_spec.rb
|
265
268
|
- spec/storey/schemas_spec.rb
|
269
|
+
- spec/storey/sql_dumper_spec.rb
|
266
270
|
- spec/storey/suffixify_spec.rb
|
267
271
|
- spec/storey/switch_spec.rb
|
268
272
|
- spec/tasks/storey_rake_spec.rb
|
File without changes
|