dm-migrations 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dm-migrations/version.rb +2 -2
- data/lib/migration.rb +1 -1
- data/lib/sql/table_creator.rb +2 -1
- data/spec/integration/sql_spec.rb +4 -3
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/migration_spec.rb +6 -7
- data/spec/unit/sql/column_spec.rb +1 -2
- data/spec/unit/sql/postgresql_spec.rb +0 -2
- data/spec/unit/sql/sqlite3_extensions_spec.rb +0 -1
- data/spec/unit/sql/table_creator_spec.rb +2 -2
- data/spec/unit/sql/table_modifier_spec.rb +1 -1
- data/spec/unit/sql/table_spec.rb +2 -2
- data/spec/unit/sql_spec.rb +1 -1
- metadata +3 -3
data/lib/migration.rb
CHANGED
data/lib/sql/table_creator.rb
CHANGED
@@ -36,6 +36,8 @@ module SQL
|
|
36
36
|
|
37
37
|
def build_type(type_class)
|
38
38
|
schema = {:name => @name, :quote_column_name => quoted_name}.merge(@opts)
|
39
|
+
schema[:serial?] ||= schema[:serial]
|
40
|
+
schema[:nullable?] ||= schema[:nullable]
|
39
41
|
schema = @adapter.class.type_map[type_class].merge(schema)
|
40
42
|
@adapter.property_schema_statement(schema)
|
41
43
|
end
|
@@ -52,4 +54,3 @@ module SQL
|
|
52
54
|
end
|
53
55
|
|
54
56
|
end
|
55
|
-
|
@@ -7,6 +7,7 @@ require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
|
7
7
|
describe DataMapper::Migration, "#create_table helper" do
|
8
8
|
before do
|
9
9
|
@creator = DataMapper::Migration::TableCreator.new(repository(adapter).adapter, :people) do
|
10
|
+
column :id, Integer, :serial => true
|
10
11
|
column :name, String
|
11
12
|
column :long_string, String, :size => 200
|
12
13
|
end
|
@@ -32,18 +33,18 @@ require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
|
32
33
|
|
33
34
|
it "should have an array of columns" do
|
34
35
|
@creator.instance_eval("@columns").should be_kind_of(Array)
|
35
|
-
@creator.instance_eval("@columns").should have(
|
36
|
+
@creator.instance_eval("@columns").should have(3).items
|
36
37
|
@creator.instance_eval("@columns").first.should be_kind_of(DataMapper::Migration::TableCreator::Column)
|
37
38
|
end
|
38
39
|
|
39
40
|
it "should quote the table name for the adapter" do
|
40
41
|
@creator.quoted_table_name.should == (adapter == :mysql ? '`people`' : '"people"')
|
41
42
|
end
|
42
|
-
|
43
|
+
|
43
44
|
it "should allow for custom options" do
|
44
45
|
columns = @creator.instance_eval("@columns")
|
45
46
|
col = columns.detect{|c| c.name == "long_string"}
|
46
|
-
col.instance_eval("@type").should include("200")
|
47
|
+
col.instance_eval("@type").should include("200")
|
47
48
|
end
|
48
49
|
|
49
50
|
end
|
data/spec/spec.opts
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/unit/migration_spec.rb
CHANGED
@@ -46,7 +46,7 @@ describe 'Migration' do
|
|
46
46
|
@adapter.should_receive(:class).and_return(DataMapper::Adapters::Sqlite3Adapter)
|
47
47
|
DataMapper::Migration.new(1, :do_nothing, {}) {}
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
it 'should extend the adapter with the right module' do
|
51
51
|
@adapter.should_receive(:extend).with(SQL::Sqlite3)
|
52
52
|
DataMapper::Migration.new(1, :do_nothing, {}) {}
|
@@ -64,10 +64,10 @@ describe 'Migration' do
|
|
64
64
|
m.instance_variable_get(:@verbose).should be_false
|
65
65
|
end
|
66
66
|
|
67
|
-
it 'should set @verbose to true by default' do
|
67
|
+
it 'should set @verbose to true by default' do
|
68
68
|
@m.instance_variable_get(:@verbose).should be_true
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
it 'should set the @up_action to an empty block' do
|
72
72
|
@m.instance_variable_get(:@up_action).should be_kind_of(Proc)
|
73
73
|
end
|
@@ -77,7 +77,7 @@ describe 'Migration' do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
it 'should evaluate the given block'
|
80
|
-
|
80
|
+
|
81
81
|
end
|
82
82
|
|
83
83
|
it 'should set the @up_action when #up is called with a block' do
|
@@ -166,7 +166,7 @@ describe 'Migration' do
|
|
166
166
|
|
167
167
|
end
|
168
168
|
|
169
|
-
describe 'methods used in the action blocks' do
|
169
|
+
describe 'methods used in the action blocks' do
|
170
170
|
|
171
171
|
describe '#execute' do
|
172
172
|
before do
|
@@ -199,7 +199,7 @@ describe 'Migration' do
|
|
199
199
|
SQL::TableCreator.should_receive(:new).with(@adapter, :users, {}).and_return(@tc)
|
200
200
|
@m.create_table(:users) { }
|
201
201
|
end
|
202
|
-
|
202
|
+
|
203
203
|
it 'should convert the TableCreator object to an sql statement' do
|
204
204
|
@tc.should_receive(:to_sql).and_return('CREATE TABLE')
|
205
205
|
@m.create_table(:users) { }
|
@@ -444,4 +444,3 @@ describe 'Migration' do
|
|
444
444
|
|
445
445
|
end
|
446
446
|
end
|
447
|
-
|
@@ -4,7 +4,7 @@ require Pathname(__FILE__).dirname + '../../spec_helper'
|
|
4
4
|
require Pathname(__FILE__).dirname + '../../../lib/sql/column'
|
5
5
|
|
6
6
|
describe SQL::Column do
|
7
|
-
before do
|
7
|
+
before do
|
8
8
|
@column = SQL::Column.new
|
9
9
|
end
|
10
10
|
|
@@ -15,4 +15,3 @@ describe SQL::Column do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
18
|
-
|
@@ -46,7 +46,7 @@ describe 'SQL module' do
|
|
46
46
|
@adapter.should_receive(:quote_table_name).with('users').and_return(%{'users'})
|
47
47
|
@tc.quoted_table_name.should == %{'users'}
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
it 'should initialze a new column and add it to the list of columns' do
|
51
51
|
col = mock('column')
|
52
52
|
SQL::TableCreator::Column.should_receive(:new).with(@adapter, :foo, :bar, {}).and_return(col)
|
@@ -55,7 +55,7 @@ describe 'SQL module' do
|
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should output an SQL CREATE statement to build itself' do
|
58
|
-
@tc.to_sql.should ==
|
58
|
+
@tc.to_sql.should ==
|
59
59
|
%{CREATE TABLE 'users' ()}
|
60
60
|
end
|
61
61
|
|
data/spec/unit/sql/table_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require Pathname(__FILE__).dirname + '../../spec_helper'
|
|
4
4
|
require Pathname(__FILE__).dirname + '../../../lib/sql/table'
|
5
5
|
|
6
6
|
describe SQL::Table do
|
7
|
-
before do
|
7
|
+
before do
|
8
8
|
@table = SQL::Table.new
|
9
9
|
end
|
10
10
|
|
@@ -23,7 +23,7 @@ describe SQL::Table do
|
|
23
23
|
column_a = mock('column', :name => 'id')
|
24
24
|
column_b = mock('column', :name => 'login')
|
25
25
|
@table.columns = [column_a, column_b]
|
26
|
-
|
26
|
+
|
27
27
|
@table.column('id').should == column_a
|
28
28
|
end
|
29
29
|
|
data/spec/unit/sql_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Sadauskas
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-08-21 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.4
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hoe
|