migration_collapser 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/GPL_LICENSE +674 -0
- data/MIT_LICENSE +22 -0
- data/README.rdoc +21 -0
- data/Rakefile +6 -0
- data/VERSION +1 -0
- data/bin/collapse_migrations +4 -0
- data/lib/migration_collapser/file_replacer.rb +64 -0
- data/lib/migration_collapser/rails_loader.rb +19 -0
- data/lib/migration_collapser/revision_finder.rb +13 -0
- data/lib/migration_collapser/runner.rb +9 -0
- data/lib/migration_collapser/templates/initial_schema_migration.rb +70 -0
- data/lib/migration_collapser/version.rb +9 -0
- data/lib/migration_collapser.rb +11 -0
- data/rake_tasks/flog.rb +10 -0
- data/rake_tasks/gem.rb +27 -0
- data/rake_tasks/rdoc.rb +16 -0
- data/rake_tasks/rspec.rb +20 -0
- data/rake_tasks/sloc.rb +16 -0
- data/rake_tasks/tags.rb +23 -0
- data/spec/migration_collapser/file_replacer_spec.rb +130 -0
- data/spec/migration_collapser/rails_loader_spec.rb +14 -0
- data/spec/migration_collapser/revision_finder_spec.rb +33 -0
- data/spec/migration_collapser/runner_spec.rb +45 -0
- data/spec/migration_collapser/version_spec.rb +21 -0
- data/spec/mysql_connection.yml +6 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +19 -0
- metadata +96 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module MigrationCollapser
|
4
|
+
describe RailsLoader do
|
5
|
+
before do
|
6
|
+
@loader = RailsLoader
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should load Dir.getwd + /config/environment.rb" do
|
10
|
+
@loader.should_receive(:require).with(File.expand_path(Dir.getwd) + "/config/environment")
|
11
|
+
@loader.load
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module MigrationCollapser
|
4
|
+
describe RevisionFinder do
|
5
|
+
before do
|
6
|
+
SchemaMigration.delete_all
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should find the revision number" do
|
10
|
+
SchemaMigration.create!(:version => "1")
|
11
|
+
RevisionFinder.find.should == "1"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should find the correct revision number" do
|
15
|
+
SchemaMigration.create!(:version => "2")
|
16
|
+
RevisionFinder.find.should == "2"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should find the latest one" do
|
20
|
+
SchemaMigration.create!(:version => 2)
|
21
|
+
SchemaMigration.create!(:version => 1)
|
22
|
+
|
23
|
+
RevisionFinder.find.should == "2"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should find the latest one independent of creation order" do
|
27
|
+
SchemaMigration.create!(:version => 1)
|
28
|
+
SchemaMigration.create!(:version => 2)
|
29
|
+
|
30
|
+
RevisionFinder.find.should == "2"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module MigrationCollapser
|
4
|
+
describe Runner do
|
5
|
+
before do
|
6
|
+
RailsLoader.stub!(:load)
|
7
|
+
RevisionFinder.stub!(:find).and_return "1234"
|
8
|
+
|
9
|
+
@replacer = mock 'replacer', :replace => true
|
10
|
+
FileReplacer.stub!(:new).and_return @replacer
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should load rails" do
|
14
|
+
RailsLoader.should_receive(:load)
|
15
|
+
Runner.run
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should find the revision" do
|
19
|
+
RevisionFinder.should_receive(:find).and_return "1234"
|
20
|
+
Runner.run
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should instantiate a file replacer" do
|
24
|
+
FileReplacer.should_receive(:new).and_return @replacer
|
25
|
+
Runner.run
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should instantiate the file replacer with the revision number" do
|
29
|
+
RevisionFinder.stub!(:find).and_return "1234"
|
30
|
+
FileReplacer.should_receive(:new).with("1234").and_return @replacer
|
31
|
+
Runner.run
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should use the correct revision number" do
|
35
|
+
RevisionFinder.stub!(:find).and_return "1111"
|
36
|
+
FileReplacer.should_receive(:new).with("1111").and_return @replacer
|
37
|
+
Runner.run
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should replace the files" do
|
41
|
+
@replacer.should_receive(:replace)
|
42
|
+
Runner.run
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe MigrationCollapser do
|
4
|
+
describe "VERSION" do
|
5
|
+
it "should be at 0.0.0" do
|
6
|
+
MigrationCollapser::Version::STRING.should == "0.1.0"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should have major as 0" do
|
10
|
+
MigrationCollapser::Version::MAJOR.should == 0
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should have minor as 0" do
|
14
|
+
MigrationCollapser::Version::MINOR.should == 1
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have tiny as 0" do
|
18
|
+
MigrationCollapser::Version::TINY.should == 0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "spec"
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/migration_collapser")
|
3
|
+
|
4
|
+
require 'mysql'
|
5
|
+
require 'active_record'
|
6
|
+
|
7
|
+
db_file = File.dirname(__FILE__) + "/mysql_connection.yml"
|
8
|
+
ActiveRecord::Base.establish_connection YAML.load(File.read(db_file))
|
9
|
+
ActiveRecord::Migration.verbose = false
|
10
|
+
|
11
|
+
ActiveRecord::Schema.define do
|
12
|
+
create_table :schema_migrations, :force => true do |t|
|
13
|
+
t.string :version
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class SchemaMigration < ActiveRecord::Base
|
18
|
+
validates_presence_of :version
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: migration_collapser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Taylor
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-25 00:00:00 -05:00
|
13
|
+
default_executable: collapse_migrations
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: using
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: Collapse migrations already run in production
|
26
|
+
email: scott@railsnewbie.com
|
27
|
+
executables:
|
28
|
+
- collapse_migrations
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.rdoc
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- GPL_LICENSE
|
36
|
+
- MIT_LICENSE
|
37
|
+
- README.rdoc
|
38
|
+
- Rakefile
|
39
|
+
- VERSION
|
40
|
+
- bin/collapse_migrations
|
41
|
+
- lib/migration_collapser.rb
|
42
|
+
- lib/migration_collapser/file_replacer.rb
|
43
|
+
- lib/migration_collapser/rails_loader.rb
|
44
|
+
- lib/migration_collapser/revision_finder.rb
|
45
|
+
- lib/migration_collapser/runner.rb
|
46
|
+
- lib/migration_collapser/templates/initial_schema_migration.rb
|
47
|
+
- lib/migration_collapser/version.rb
|
48
|
+
- rake_tasks/flog.rb
|
49
|
+
- rake_tasks/gem.rb
|
50
|
+
- rake_tasks/rdoc.rb
|
51
|
+
- rake_tasks/rspec.rb
|
52
|
+
- rake_tasks/sloc.rb
|
53
|
+
- rake_tasks/tags.rb
|
54
|
+
- spec/migration_collapser/file_replacer_spec.rb
|
55
|
+
- spec/migration_collapser/rails_loader_spec.rb
|
56
|
+
- spec/migration_collapser/revision_finder_spec.rb
|
57
|
+
- spec/migration_collapser/runner_spec.rb
|
58
|
+
- spec/migration_collapser/version_spec.rb
|
59
|
+
- spec/mysql_connection.yml
|
60
|
+
- spec/spec.opts
|
61
|
+
- spec/spec_helper.rb
|
62
|
+
has_rdoc: true
|
63
|
+
homepage: http://github.com/smtlaissezfaire/migration_collapser
|
64
|
+
licenses: []
|
65
|
+
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options:
|
68
|
+
- --charset=UTF-8
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: "0"
|
76
|
+
version:
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: "0"
|
82
|
+
version:
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.3.5
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Collapse rails migrations
|
90
|
+
test_files:
|
91
|
+
- spec/migration_collapser/file_replacer_spec.rb
|
92
|
+
- spec/migration_collapser/rails_loader_spec.rb
|
93
|
+
- spec/migration_collapser/revision_finder_spec.rb
|
94
|
+
- spec/migration_collapser/runner_spec.rb
|
95
|
+
- spec/migration_collapser/version_spec.rb
|
96
|
+
- spec/spec_helper.rb
|