standalone_migrations 0.4.10 → 0.4.11
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +8 -0
- data/VERSION +1 -1
- data/lib/tasks/standalone_migrations.rb +10 -1
- data/spec/standalone_migrations_spec.rb +38 -0
- data/standalone_migrations.gemspec +2 -5
- metadata +5 -5
data/README.markdown
CHANGED
@@ -109,6 +109,14 @@ This will create a migration in db/migrations/
|
|
109
109
|
|
110
110
|
rake db:migrate:up VERSION=20081220234130
|
111
111
|
|
112
|
+
### To revert your last migration
|
113
|
+
|
114
|
+
rake db:rollback
|
115
|
+
|
116
|
+
### To revert your last 3 migrations
|
117
|
+
|
118
|
+
rake db:rollback STEP=3
|
119
|
+
|
112
120
|
## Sub-namespacing
|
113
121
|
|
114
122
|
When working with multiple databases in a single application it is convenient
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.11
|
@@ -83,6 +83,15 @@ class MigratorTasks < ::Rake::TaskLib
|
|
83
83
|
end
|
84
84
|
Rake::Task["db:#{sub_namespace_with_separator}schema:dump"].execute
|
85
85
|
end
|
86
|
+
|
87
|
+
desc "Revert the last migration applied. Revert multiple migrations with STEP=x."
|
88
|
+
task :rollback => :ar_init do
|
89
|
+
step = ENV['STEP'] ? ENV['STEP'].to_i : 1
|
90
|
+
@migrations.each do |path|
|
91
|
+
ActiveRecord::Migrator.rollback(path, step)
|
92
|
+
end
|
93
|
+
Rake::Task["db:#{sub_namespace_with_separator}schema:dump"].execute
|
94
|
+
end
|
86
95
|
|
87
96
|
desc "Retrieves the current schema version number"
|
88
97
|
task :version => :ar_init do
|
@@ -258,7 +267,7 @@ class MigratorTasks < ::Rake::TaskLib
|
|
258
267
|
task :purge => "db:#{sub_namespace_with_separator}ar_init" do
|
259
268
|
config = ActiveRecord::Base.configurations['test']
|
260
269
|
case config["adapter"]
|
261
|
-
when "mysql"
|
270
|
+
when *["mysql", "mysql2"]
|
262
271
|
ActiveRecord::Base.establish_connection(:test)
|
263
272
|
ActiveRecord::Base.connection.recreate_database(config["database"], config)
|
264
273
|
when "postgresql" #TODO i doubt this will work <-> methods are not defined
|
@@ -57,6 +57,20 @@ describe 'Standalone migrations' do
|
|
57
57
|
end
|
58
58
|
TXT
|
59
59
|
end
|
60
|
+
|
61
|
+
def write_reversible_migration
|
62
|
+
write "db/migrations/20110703102233_create_tests.rb", <<-TXT
|
63
|
+
class CreateTests < ActiveRecord::Migration
|
64
|
+
def self.up
|
65
|
+
puts "UP-CreateTests"
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.down
|
69
|
+
puts "DOWN-CreateTests"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
TXT
|
73
|
+
end
|
60
74
|
|
61
75
|
def write_multiple_migrations
|
62
76
|
write_rakefile %{t.migrations = "db/migrations", "db/migrations2"}
|
@@ -198,6 +212,30 @@ end
|
|
198
212
|
end
|
199
213
|
end
|
200
214
|
end
|
215
|
+
|
216
|
+
describe 'db:rollback' do
|
217
|
+
it "does nothing when no migrations have been run" do
|
218
|
+
run("rake db:rollback").should =~ /SUCCESS/
|
219
|
+
end
|
220
|
+
|
221
|
+
it "rolls back the last migration if one has been applied" do
|
222
|
+
write_reversible_migration
|
223
|
+
run("rake db:migrate")
|
224
|
+
|
225
|
+
result = run("rake db:rollback")
|
226
|
+
result.should =~ /SUCCESS/
|
227
|
+
result.should =~ /reverted/
|
228
|
+
end
|
229
|
+
|
230
|
+
it "rolls back multiple migrations if the STEP argument is given" do
|
231
|
+
write_multiple_migrations
|
232
|
+
run("rake db:migrate")
|
233
|
+
|
234
|
+
result = run("rake db:rollback STEP=2")
|
235
|
+
result.should =~ /SUCCESS/
|
236
|
+
result.should =~ /reverted/
|
237
|
+
end
|
238
|
+
end
|
201
239
|
|
202
240
|
describe 'db:migrate:down' do
|
203
241
|
context "single migration path" do
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{standalone_migrations}
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.11"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Todd Huss", "Michael Grosser"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-07-07}
|
13
13
|
s.email = %q{thuss@gabrito.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.markdown"
|
@@ -30,9 +30,6 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.require_paths = ["lib"]
|
31
31
|
s.rubygems_version = %q{1.3.7}
|
32
32
|
s.summary = %q{A thin wrapper to use Rails Migrations in non Rails projects}
|
33
|
-
s.test_files = [
|
34
|
-
"spec/standalone_migrations_spec.rb"
|
35
|
-
]
|
36
33
|
|
37
34
|
if s.respond_to? :specification_version then
|
38
35
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 11
|
9
|
+
version: 0.4.11
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Todd Huss
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-07 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -95,5 +95,5 @@ rubygems_version: 1.3.7
|
|
95
95
|
signing_key:
|
96
96
|
specification_version: 3
|
97
97
|
summary: A thin wrapper to use Rails Migrations in non Rails projects
|
98
|
-
test_files:
|
99
|
-
|
98
|
+
test_files: []
|
99
|
+
|