migration_tools 0.1.4 → 0.1.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/VERSION +1 -1
- data/lib/migration_tools/migration_extension.rb +15 -1
- data/lib/migration_tools.rb +8 -0
- data/migration_tools.gemspec +2 -2
- data/test/test_migration_tools.rb +16 -0
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module MigrationTools
|
2
2
|
module MigrationExtension
|
3
|
+
|
3
4
|
attr_accessor :migration_group
|
5
|
+
|
4
6
|
def group(arg = nil)
|
5
7
|
unless MigrationTools::MIGRATION_GROUPS.member?(arg.to_s)
|
6
8
|
raise "Invalid group \"#{arg.to_s}\" - valid groups are #{MigrationTools::MIGRATION_GROUPS.inspect}"
|
@@ -8,8 +10,20 @@ module MigrationTools
|
|
8
10
|
|
9
11
|
self.migration_group = arg.to_s
|
10
12
|
end
|
13
|
+
|
14
|
+
def migrate_with_forced_groups(direction)
|
15
|
+
if MigrationTools.forced? && migration_group.blank?
|
16
|
+
raise "Cowardly refusing to run migration without group. Ner ner ner ner ner, shame shame shame."
|
17
|
+
end
|
18
|
+
migrate_without_forced_groups(direction)
|
19
|
+
end
|
11
20
|
end
|
12
21
|
end
|
13
22
|
|
14
|
-
ActiveRecord::Migration.class_eval
|
23
|
+
ActiveRecord::Migration.class_eval do
|
24
|
+
extend MigrationTools::MigrationExtension
|
25
|
+
class << self
|
26
|
+
alias_method_chain :migrate, :forced_groups
|
27
|
+
end
|
28
|
+
end
|
15
29
|
ActiveRecord::MigrationProxy.delegate :migration_group, :to => :migration
|
data/lib/migration_tools.rb
CHANGED
@@ -5,5 +5,13 @@ require 'migration_tools/migration_extension'
|
|
5
5
|
require 'migration_tools/tasks'
|
6
6
|
|
7
7
|
module MigrationTools
|
8
|
+
def self.forced?
|
9
|
+
!!@forced
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.forced!
|
13
|
+
@forced = true
|
14
|
+
end
|
15
|
+
|
8
16
|
MIGRATION_GROUPS = [ 'before', 'during', 'after', 'change' ]
|
9
17
|
end
|
data/migration_tools.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{migration_tools}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Morten Primdahl"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-13}
|
13
13
|
s.description = %q{Suite of task extensions for Rails 2.3 that makes managing migrations easier of more nimble}
|
14
14
|
s.email = %q{morten@zendesk.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -63,6 +63,22 @@ class TestMigrationTools < Test::Unit::TestCase
|
|
63
63
|
assert_equal "change", proxy.migration_group
|
64
64
|
end
|
65
65
|
|
66
|
+
def test_forcing
|
67
|
+
assert !MigrationTools.forced?
|
68
|
+
Kappa.migrate("up")
|
69
|
+
|
70
|
+
MigrationTools.forced!
|
71
|
+
assert MigrationTools.forced?
|
72
|
+
|
73
|
+
Alpha.migrate("up")
|
74
|
+
begin
|
75
|
+
Kappa.migrate("up")
|
76
|
+
fail "You should not be able to run migrations without groups in forced mode"
|
77
|
+
rescue RuntimeError => e
|
78
|
+
assert e.message =~ /Cowardly refusing/
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
66
82
|
def test_task_presence
|
67
83
|
assert Rake::Task["db:migrate:list"]
|
68
84
|
assert Rake::Task["db:migrate:group"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: migration_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Morten Primdahl
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-13 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|