dm-migrations 0.9.10 → 0.9.11

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.
@@ -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
- * No changes this version
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', "~>#{GEM_VERSION}"]]
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
 
@@ -1,5 +1,5 @@
1
1
  module DataMapper
2
2
  class Migration
3
- VERSION = '0.9.10'
3
+ VERSION = '0.9.11'
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  require 'rubygems'
2
- gem 'dm-core', '~>0.9.10'
2
+ gem 'dm-core', '0.9.11'
3
3
  require 'dm-core'
4
4
  require 'benchmark'
5
5
  require File.dirname(__FILE__) + '/sql'
@@ -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]
@@ -32,6 +32,10 @@ module SQL
32
32
  statement
33
33
  end
34
34
 
35
+ def create_table_statement(quoted_table_name)
36
+ "CREATE TABLE #{quoted_table_name}"
37
+ end
38
+
35
39
  class Table < SQL::Table
36
40
  def initialize(adapter, table_name)
37
41
  @adapter, @name = adapter, table_name
@@ -17,6 +17,10 @@ module SQL
17
17
  # do nothing, sqlite will automatically create the database file
18
18
  end
19
19
 
20
+ def create_table_statement(quoted_table_name)
21
+ "CREATE TABLE #{quoted_table_name}"
22
+ end
23
+
20
24
  def supports_serial?
21
25
  true
22
26
  end
@@ -21,7 +21,7 @@ module SQL
21
21
  end
22
22
 
23
23
  def to_sql
24
- "CREATE TABLE #{quoted_table_name} (#{@columns.map{ |c| c.to_sql }.join(', ')})"
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[:nullable?] ||= schema[:nullable] || !schema[:not_null]
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
@@ -1,7 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'rubygems'
3
3
 
4
- gem 'rspec', '~>1.1.11'
4
+ gem 'rspec', '~>1.2'
5
5
  require 'spec'
6
6
 
7
7
  require Pathname(__FILE__).dirname.parent.expand_path + 'lib/dm-migrations'
@@ -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
@@ -1,5 +1,5 @@
1
1
  begin
2
- gem 'rspec', '~>1.1.11'
2
+ gem 'rspec', '~>1.2'
3
3
  require 'spec'
4
4
  require 'spec/rake/spectask'
5
5
 
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.10
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-01-19 00:00:00 -08:00
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.10
23
+ version: 0.9.11
24
24
  version:
25
25
  description: DataMapper plugin for writing and speccing migrations
26
26
  email: