ardm-migrations 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/.travis.yml +11 -0
- data/Gemfile +53 -0
- data/LICENSE +20 -0
- data/README.rdoc +39 -0
- data/Rakefile +4 -0
- data/ardm-migrations.gemspec +27 -0
- data/db/migrations/1_create_people_table.rb +12 -0
- data/db/migrations/2_add_dob_to_people.rb +13 -0
- data/db/migrations/config.rb +4 -0
- data/examples/Rakefile +144 -0
- data/examples/sample_migration.rb +58 -0
- data/examples/sample_migration_spec.rb +50 -0
- data/lib/ardm-migrations.rb +1 -0
- data/lib/dm-migrations/adapters/dm-do-adapter.rb +295 -0
- data/lib/dm-migrations/adapters/dm-mysql-adapter.rb +299 -0
- data/lib/dm-migrations/adapters/dm-oracle-adapter.rb +332 -0
- data/lib/dm-migrations/adapters/dm-postgres-adapter.rb +159 -0
- data/lib/dm-migrations/adapters/dm-sqlite-adapter.rb +96 -0
- data/lib/dm-migrations/adapters/dm-sqlserver-adapter.rb +177 -0
- data/lib/dm-migrations/adapters/dm-yaml-adapter.rb +23 -0
- data/lib/dm-migrations/auto_migration.rb +239 -0
- data/lib/dm-migrations/exceptions/duplicate_migration.rb +6 -0
- data/lib/dm-migrations/migration.rb +300 -0
- data/lib/dm-migrations/migration_runner.rb +85 -0
- data/lib/dm-migrations/sql/column.rb +5 -0
- data/lib/dm-migrations/sql/mysql.rb +61 -0
- data/lib/dm-migrations/sql/postgres.rb +82 -0
- data/lib/dm-migrations/sql/sqlite.rb +51 -0
- data/lib/dm-migrations/sql/table.rb +15 -0
- data/lib/dm-migrations/sql/table_creator.rb +109 -0
- data/lib/dm-migrations/sql/table_modifier.rb +57 -0
- data/lib/dm-migrations/sql.rb +5 -0
- data/lib/dm-migrations/version.rb +5 -0
- data/lib/dm-migrations.rb +3 -0
- data/lib/spec/example/migration_example_group.rb +73 -0
- data/lib/spec/matchers/migration_matchers.rb +106 -0
- data/spec/integration/auto_migration_spec.rb +553 -0
- data/spec/integration/auto_upgrade_spec.rb +40 -0
- data/spec/integration/migration_runner_spec.rb +89 -0
- data/spec/integration/migration_spec.rb +157 -0
- data/spec/integration/sql_spec.rb +250 -0
- data/spec/isolated/require_after_setup_spec.rb +30 -0
- data/spec/isolated/require_before_setup_spec.rb +30 -0
- data/spec/isolated/require_spec.rb +25 -0
- data/spec/rcov.opts +6 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/unit/migration_spec.rb +453 -0
- data/spec/unit/sql/column_spec.rb +14 -0
- data/spec/unit/sql/postgres_spec.rb +97 -0
- data/spec/unit/sql/sqlite_extensions_spec.rb +108 -0
- data/spec/unit/sql/table_creator_spec.rb +94 -0
- data/spec/unit/sql/table_modifier_spec.rb +49 -0
- data/spec/unit/sql/table_spec.rb +28 -0
- data/spec/unit/sql_spec.rb +7 -0
- data/tasks/spec.rake +38 -0
- data/tasks/yard.rake +9 -0
- data/tasks/yardstick.rake +19 -0
- metadata +150 -0
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'SQL module' do
|
4
|
+
describe 'TableCreator' do
|
5
|
+
before do
|
6
|
+
@adapter = mock('adapter')
|
7
|
+
@adapter.stub!(:quote_name).and_return(%{'users'})
|
8
|
+
@tc = SQL::TableCreator.new(@adapter, 'users') { }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'initialization' do
|
12
|
+
it 'should set @adapter to the adapter' do
|
13
|
+
@tc.instance_variable_get("@adapter").should == @adapter
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should set @table_name to the stringified table name' do
|
17
|
+
@tc.instance_variable_get("@table_name").should == 'users'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should set @opts to the options hash' do
|
21
|
+
@tc.instance_variable_get("@opts").should == {}
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should set @columns to an empty array' do
|
25
|
+
@tc.instance_variable_get("@columns").should == []
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should evaluate the given block' do
|
29
|
+
block = proc { column :foo, :bar }
|
30
|
+
col = mock('column')
|
31
|
+
SQL::TableCreator::Column.should_receive(:new).with(@adapter, :foo, :bar, {}).and_return(col)
|
32
|
+
tc = SQL::TableCreator.new(@adapter, 'users', {}, &block)
|
33
|
+
tc.instance_variable_get("@columns").should == [col]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should have a table_name' do
|
38
|
+
@tc.should respond_to(:table_name)
|
39
|
+
@tc.table_name.should == 'users'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should use the adapter to quote the table name' do
|
43
|
+
@adapter.should_receive(:quote_name).with('users').and_return(%{'users'})
|
44
|
+
@tc.quoted_table_name.should == %{'users'}
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should initialze a new column and add it to the list of columns' do
|
48
|
+
col = mock('column')
|
49
|
+
SQL::TableCreator::Column.should_receive(:new).with(@adapter, :foo, :bar, {}).and_return(col)
|
50
|
+
@tc.column(:foo, :bar)
|
51
|
+
@tc.instance_variable_get("@columns").should == [col]
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should output an SQL CREATE statement to build itself' do
|
55
|
+
@adapter.stub!(:table_options).and_return("")
|
56
|
+
@tc.to_sql.should ==
|
57
|
+
%{CREATE TABLE 'users' ()}
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'Column' do
|
61
|
+
before do
|
62
|
+
connection = mock('Connection')
|
63
|
+
|
64
|
+
@adapter.stub!(:quote_column_name).and_return(%{'id'})
|
65
|
+
@adapter.class.stub!(:type_map).and_return(Integer => {:type => 'int'})
|
66
|
+
@adapter.stub!(:property_schema_statement).and_return("SOME SQL")
|
67
|
+
@adapter.stub!(:with_connection).and_yield(connection)
|
68
|
+
@c = SQL::TableCreator::Column.new(@adapter, 'id', Integer, :serial => true)
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'initialization' do
|
72
|
+
it 'should set @adapter to the adapter' do
|
73
|
+
@c.instance_variable_get("@adapter").should == @adapter
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should set @name to the stringified name' do
|
77
|
+
@c.instance_variable_get("@name").should == 'id'
|
78
|
+
end
|
79
|
+
|
80
|
+
# TODO make this really the type, not this sql bullshit
|
81
|
+
it 'should set @type to the type' do
|
82
|
+
@c.instance_variable_get("@type").should == "SOME SQL"
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should set @opts to the options hash' do
|
86
|
+
@c.instance_variable_get("@opts").should == {:serial => true}
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'SQL module' do
|
4
|
+
describe 'TableModifier' do
|
5
|
+
before do
|
6
|
+
@adapter = mock('adapter')
|
7
|
+
@adapter.stub!(:quote_name).and_return(%{'users'})
|
8
|
+
@tc = SQL::TableModifier.new(@adapter, :users) { }
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'initialization' do
|
12
|
+
it 'should set @adapter to the adapter' do
|
13
|
+
@tc.instance_variable_get("@adapter").should == @adapter
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should set @table_name to the stringified table name' do
|
17
|
+
@tc.instance_variable_get("@table_name").should == 'users'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should set @opts to the options hash' do
|
21
|
+
@tc.instance_variable_get("@opts").should == {}
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should set @statements to an empty array' do
|
25
|
+
@tc.instance_variable_get("@statements").should == []
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should evaluate the given block' do
|
29
|
+
block = proc { column :foo, :bar }
|
30
|
+
col = mock('column')
|
31
|
+
SQL::TableCreator::Column.should_receive(:new).with(@adapter, :foo, :bar, {}).and_return(col)
|
32
|
+
tc = SQL::TableCreator.new(@adapter, 'users', {}, &block)
|
33
|
+
tc.instance_variable_get("@columns").should == [col]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should have a table_name' do
|
38
|
+
@tc.should respond_to(:table_name)
|
39
|
+
@tc.table_name.should == 'users'
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should use the adapter to quote the table name' do
|
43
|
+
@adapter.should_receive(:quote_name).with('users').and_return(%{'users'})
|
44
|
+
@tc.quoted_table_name.should == %{'users'}
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SQL::Table do
|
4
|
+
before do
|
5
|
+
@table = SQL::Table.new
|
6
|
+
end
|
7
|
+
|
8
|
+
%w{name columns}.each do |meth|
|
9
|
+
it "should have a ##{meth} attribute" do
|
10
|
+
@table.should respond_to(meth.intern)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should #to_s as the name' do
|
15
|
+
@table.name = "table_name"
|
16
|
+
@table.to_s.should == "table_name"
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should find a column by name' do
|
20
|
+
column_a = mock('column', :name => 'id')
|
21
|
+
column_b = mock('column', :name => 'login')
|
22
|
+
@table.columns = [column_a, column_b]
|
23
|
+
|
24
|
+
@table.column('id').should == column_a
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
end
|
data/tasks/spec.rake
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
spec_defaults = lambda do |spec|
|
2
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
3
|
+
spec.libs << 'lib' << 'spec'
|
4
|
+
spec.spec_opts << '--options' << 'spec/spec.opts'
|
5
|
+
end
|
6
|
+
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
|
10
|
+
Spec::Rake::SpecTask.new(:spec, &spec_defaults)
|
11
|
+
rescue LoadError
|
12
|
+
task :spec do
|
13
|
+
abort 'rspec is not available. In order to run spec, you must: gem install rspec'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
begin
|
18
|
+
require 'rcov'
|
19
|
+
require 'spec/rake/verify_rcov'
|
20
|
+
|
21
|
+
Spec::Rake::SpecTask.new(:rcov) do |rcov|
|
22
|
+
spec_defaults.call(rcov)
|
23
|
+
rcov.rcov = true
|
24
|
+
rcov.rcov_opts = File.read('spec/rcov.opts').split(/\s+/)
|
25
|
+
end
|
26
|
+
|
27
|
+
RCov::VerifyTask.new(:verify_rcov => :rcov) do |rcov|
|
28
|
+
rcov.threshold = 100
|
29
|
+
end
|
30
|
+
rescue LoadError
|
31
|
+
%w[ rcov verify_rcov ].each do |name|
|
32
|
+
task name do
|
33
|
+
abort "rcov is not available. In order to run #{name}, you must: gem install rcov"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
task :default => :spec
|
data/tasks/yard.rake
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
begin
|
2
|
+
require 'pathname'
|
3
|
+
require 'yardstick/rake/measurement'
|
4
|
+
require 'yardstick/rake/verify'
|
5
|
+
|
6
|
+
# yardstick_measure task
|
7
|
+
Yardstick::Rake::Measurement.new
|
8
|
+
|
9
|
+
# verify_measurements task
|
10
|
+
Yardstick::Rake::Verify.new do |verify|
|
11
|
+
verify.threshold = 100
|
12
|
+
end
|
13
|
+
rescue LoadError
|
14
|
+
%w[ yardstick_measure verify_measurements ].each do |name|
|
15
|
+
task name.to_s do
|
16
|
+
abort "Yardstick is not available. In order to run #{name}, you must: gem install yardstick"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ardm-migrations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Martin Emde
|
8
|
+
- Paul Sadauskas
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-01-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ardm-core
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.2'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.2'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: rake
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0.9'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0.9'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rspec
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.3'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.3'
|
56
|
+
description: Ardm fork of dm-migrations
|
57
|
+
email:
|
58
|
+
- me@martinemde.com
|
59
|
+
- psadauskas [a] gmail [d] com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files:
|
63
|
+
- LICENSE
|
64
|
+
- README.rdoc
|
65
|
+
files:
|
66
|
+
- ".gitignore"
|
67
|
+
- ".travis.yml"
|
68
|
+
- Gemfile
|
69
|
+
- LICENSE
|
70
|
+
- README.rdoc
|
71
|
+
- Rakefile
|
72
|
+
- ardm-migrations.gemspec
|
73
|
+
- db/migrations/1_create_people_table.rb
|
74
|
+
- db/migrations/2_add_dob_to_people.rb
|
75
|
+
- db/migrations/config.rb
|
76
|
+
- examples/Rakefile
|
77
|
+
- examples/sample_migration.rb
|
78
|
+
- examples/sample_migration_spec.rb
|
79
|
+
- lib/ardm-migrations.rb
|
80
|
+
- lib/dm-migrations.rb
|
81
|
+
- lib/dm-migrations/adapters/dm-do-adapter.rb
|
82
|
+
- lib/dm-migrations/adapters/dm-mysql-adapter.rb
|
83
|
+
- lib/dm-migrations/adapters/dm-oracle-adapter.rb
|
84
|
+
- lib/dm-migrations/adapters/dm-postgres-adapter.rb
|
85
|
+
- lib/dm-migrations/adapters/dm-sqlite-adapter.rb
|
86
|
+
- lib/dm-migrations/adapters/dm-sqlserver-adapter.rb
|
87
|
+
- lib/dm-migrations/adapters/dm-yaml-adapter.rb
|
88
|
+
- lib/dm-migrations/auto_migration.rb
|
89
|
+
- lib/dm-migrations/exceptions/duplicate_migration.rb
|
90
|
+
- lib/dm-migrations/migration.rb
|
91
|
+
- lib/dm-migrations/migration_runner.rb
|
92
|
+
- lib/dm-migrations/sql.rb
|
93
|
+
- lib/dm-migrations/sql/column.rb
|
94
|
+
- lib/dm-migrations/sql/mysql.rb
|
95
|
+
- lib/dm-migrations/sql/postgres.rb
|
96
|
+
- lib/dm-migrations/sql/sqlite.rb
|
97
|
+
- lib/dm-migrations/sql/table.rb
|
98
|
+
- lib/dm-migrations/sql/table_creator.rb
|
99
|
+
- lib/dm-migrations/sql/table_modifier.rb
|
100
|
+
- lib/dm-migrations/version.rb
|
101
|
+
- lib/spec/example/migration_example_group.rb
|
102
|
+
- lib/spec/matchers/migration_matchers.rb
|
103
|
+
- spec/integration/auto_migration_spec.rb
|
104
|
+
- spec/integration/auto_upgrade_spec.rb
|
105
|
+
- spec/integration/migration_runner_spec.rb
|
106
|
+
- spec/integration/migration_spec.rb
|
107
|
+
- spec/integration/sql_spec.rb
|
108
|
+
- spec/isolated/require_after_setup_spec.rb
|
109
|
+
- spec/isolated/require_before_setup_spec.rb
|
110
|
+
- spec/isolated/require_spec.rb
|
111
|
+
- spec/rcov.opts
|
112
|
+
- spec/spec.opts
|
113
|
+
- spec/spec_helper.rb
|
114
|
+
- spec/unit/migration_spec.rb
|
115
|
+
- spec/unit/sql/column_spec.rb
|
116
|
+
- spec/unit/sql/postgres_spec.rb
|
117
|
+
- spec/unit/sql/sqlite_extensions_spec.rb
|
118
|
+
- spec/unit/sql/table_creator_spec.rb
|
119
|
+
- spec/unit/sql/table_modifier_spec.rb
|
120
|
+
- spec/unit/sql/table_spec.rb
|
121
|
+
- spec/unit/sql_spec.rb
|
122
|
+
- tasks/spec.rake
|
123
|
+
- tasks/yard.rake
|
124
|
+
- tasks/yardstick.rake
|
125
|
+
homepage: http://github.com/martinemde/ardm-migrations
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 2.2.2
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: Ardm fork of dm-migrations
|
149
|
+
test_files: []
|
150
|
+
has_rdoc:
|