dm-migrations 0.9.10 → 0.9.11
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -1
- data/Rakefile +1 -1
- data/lib/dm-migrations/version.rb +1 -1
- data/lib/migration.rb +1 -1
- data/lib/sql/mysql.rb +4 -0
- data/lib/sql/postgresql.rb +4 -0
- data/lib/sql/sqlite3.rb +4 -0
- data/lib/sql/table_creator.rb +4 -2
- data/spec/integration/sql_spec.rb +28 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/sql/table_creator_spec.rb +1 -0
- data/tasks/spec.rb +1 -1
- metadata +4 -4
data/History.txt
CHANGED
@@ -1,6 +1,16 @@
|
|
1
|
+
=== 0.9.11 / 2009-03-29
|
2
|
+
|
3
|
+
* 1 minor enhancement:
|
4
|
+
|
5
|
+
* Updated default MySQL engine to InnoDB
|
6
|
+
|
7
|
+
* 1 bug fix:
|
8
|
+
|
9
|
+
* Fix :nullable for columns
|
10
|
+
|
1
11
|
=== 0.9.10 / 2009-01-19
|
2
12
|
|
3
|
-
|
13
|
+
* No changes this version
|
4
14
|
|
5
15
|
=== 0.9.9 / 2009-01-04
|
6
16
|
|
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ AUTHOR = 'Paul Sadauskas'
|
|
12
12
|
EMAIL = 'psadauskas [a] gmail [d] com'
|
13
13
|
GEM_NAME = 'dm-migrations'
|
14
14
|
GEM_VERSION = DataMapper::Migration::VERSION
|
15
|
-
GEM_DEPENDENCIES = [['dm-core',
|
15
|
+
GEM_DEPENDENCIES = [['dm-core', GEM_VERSION]]
|
16
16
|
GEM_CLEAN = %w[ log pkg coverage ]
|
17
17
|
GEM_EXTRAS = { :has_rdoc => true, :extra_rdoc_files => %w[ README.txt LICENSE TODO History.txt ] }
|
18
18
|
|
data/lib/migration.rb
CHANGED
data/lib/sql/mysql.rb
CHANGED
@@ -21,6 +21,10 @@ module SQL
|
|
21
21
|
true
|
22
22
|
end
|
23
23
|
|
24
|
+
def create_table_statement(quoted_table_name)
|
25
|
+
"CREATE TABLE #{quoted_table_name} ENGINE = InnoDB CHARACTER SET #{character_set} COLLATE #{collation}"
|
26
|
+
end
|
27
|
+
|
24
28
|
# TODO: move to dm-more/dm-migrations
|
25
29
|
def property_schema_statement(schema)
|
26
30
|
if supports_serial? && schema[:serial]
|
data/lib/sql/postgresql.rb
CHANGED
data/lib/sql/sqlite3.rb
CHANGED
data/lib/sql/table_creator.rb
CHANGED
@@ -21,7 +21,7 @@ module SQL
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def to_sql
|
24
|
-
"
|
24
|
+
"#{@adapter.create_table_statement(quoted_table_name)} (#{@columns.map{ |c| c.to_sql }.join(', ')})"
|
25
25
|
end
|
26
26
|
|
27
27
|
# A helper for using the native NOW() SQL function in a default
|
@@ -58,7 +58,9 @@ module SQL
|
|
58
58
|
def build_type(type_class)
|
59
59
|
schema = {:name => @name, :quote_column_name => quoted_name}.merge(@opts)
|
60
60
|
schema[:serial?] ||= schema[:serial]
|
61
|
-
schema
|
61
|
+
unless schema.has_key?(:nullable?)
|
62
|
+
schema[:nullable?] = schema.has_key?(:nullable) ? schema[:nullable] : !schema[:not_null]
|
63
|
+
end
|
62
64
|
if type_class.is_a?(String)
|
63
65
|
schema[:primitive] = type_class
|
64
66
|
else
|
@@ -4,10 +4,18 @@ require Pathname(__FILE__).dirname.expand_path.parent + 'spec_helper'
|
|
4
4
|
ADAPTERS.each do |adapter|
|
5
5
|
describe "Using Adapter #{adapter}," do
|
6
6
|
describe DataMapper::Migration, "#create_table helper" do
|
7
|
+
before :all do
|
8
|
+
case adapter
|
9
|
+
when :sqlite3 then repository(adapter).adapter.extend(SQL::Sqlite3)
|
10
|
+
when :mysql then repository(adapter).adapter.extend(SQL::Mysql)
|
11
|
+
when :postgres then repository(adapter).adapter.extend(SQL::Postgresql)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
7
15
|
before do
|
8
16
|
@creator = DataMapper::Migration::TableCreator.new(repository(adapter).adapter, :people) do
|
9
17
|
column :id, Integer, :serial => true
|
10
|
-
column :name, 'varchar(50)'
|
18
|
+
column :name, 'varchar(50)', :nullable => false
|
11
19
|
column :long_string, String, :size => 200
|
12
20
|
end
|
13
21
|
end
|
@@ -46,6 +54,25 @@ ADAPTERS.each do |adapter|
|
|
46
54
|
col.instance_eval("@type").should include("200")
|
47
55
|
end
|
48
56
|
|
57
|
+
it "should generate a NOT NULL column when :nullable is false" do
|
58
|
+
@creator.instance_eval("@columns")[1].type.should match(/NOT NULL/)
|
59
|
+
end
|
60
|
+
|
61
|
+
case adapter
|
62
|
+
when :mysql
|
63
|
+
it "should create an InnoDB database for MySQL" do
|
64
|
+
#can't get an exact == comparison here because character set and collation may differ per connection
|
65
|
+
@creator.to_sql.should match(/^CREATE TABLE `people` ENGINE = InnoDB CHARACTER SET \w+ COLLATE \w+ \(`id` serial PRIMARY KEY, `name` varchar\(50\) NOT NULL, `long_string` VARCHAR\(200\)\)$/)
|
66
|
+
end
|
67
|
+
when :postgres
|
68
|
+
it "should output a CREATE TABLE statement when sent #to_sql" do
|
69
|
+
@creator.to_sql.should == %q{CREATE TABLE "people" ("id" serial PRIMARY KEY, "name" varchar(50) NOT NULL, "long_string" VARCHAR(200))}
|
70
|
+
end
|
71
|
+
when :sqlite3
|
72
|
+
it "should output a CREATE TABLE statement when sent #to_sql" do
|
73
|
+
@creator.to_sql.should == %q{CREATE TABLE "people" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "name" varchar(50) NOT NULL, "long_string" VARCHAR(200))}
|
74
|
+
end
|
75
|
+
end
|
49
76
|
end
|
50
77
|
|
51
78
|
describe DataMapper::Migration, "#modify_table helper" do
|
data/spec/spec_helper.rb
CHANGED
@@ -55,6 +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
|
+
@adapter.should_receive(:create_table_statement).with("'users'").and_return(%{CREATE TABLE 'users'})
|
58
59
|
@tc.to_sql.should ==
|
59
60
|
%{CREATE TABLE 'users' ()}
|
60
61
|
end
|
data/tasks/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.11
|
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: 2009-
|
12
|
+
date: 2009-03-29 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -18,9 +18,9 @@ dependencies:
|
|
18
18
|
version_requirement:
|
19
19
|
version_requirements: !ruby/object:Gem::Requirement
|
20
20
|
requirements:
|
21
|
-
- -
|
21
|
+
- - "="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.11
|
24
24
|
version:
|
25
25
|
description: DataMapper plugin for writing and speccing migrations
|
26
26
|
email:
|