dm-migrations 1.0.0.rc2 → 1.0.0.rc3

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.
data/Gemfile CHANGED
@@ -71,7 +71,7 @@
71
71
  source 'http://rubygems.org'
72
72
 
73
73
  DATAMAPPER = 'git://github.com/datamapper'
74
- DM_VERSION = '~> 1.0.0.rc2'
74
+ DM_VERSION = '~> 1.0.0.rc3'
75
75
 
76
76
  group :runtime do # Runtime dependencies (as in the gemspec)
77
77
 
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Paul Sadauskas
1
+ Copyright (c) 2010 Paul Sadauskas
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -10,12 +10,12 @@ begin
10
10
  gem.summary = 'DataMapper plugin for writing and speccing migrations'
11
11
  gem.description = gem.summary
12
12
  gem.email = 'psadauskas [a] gmail [d] com'
13
- gem.homepage = 'http://github.com/datamapper/dm-more/tree/master/%s' % gem.name
13
+ gem.homepage = 'http://github.com/datamapper/%s' % gem.name
14
14
  gem.authors = [ 'Paul Sadauskas' ]
15
15
 
16
16
  gem.rubyforge_project = 'datamapper'
17
17
 
18
- gem.add_dependency 'dm-core', '~> 1.0.0.rc2'
18
+ gem.add_dependency 'dm-core', '~> 1.0.0.rc3'
19
19
 
20
20
  gem.add_development_dependency 'rspec', '~> 1.3'
21
21
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.rc2
1
+ 1.0.0.rc3
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dm-migrations}
8
- s.version = "1.0.0.rc2"
8
+ s.version = "1.0.0.rc3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paul Sadauskas"]
12
- s.date = %q{2010-05-19}
12
+ s.date = %q{2010-05-27}
13
13
  s.description = %q{DataMapper plugin for writing and speccing migrations}
14
14
  s.email = %q{psadauskas [a] gmail [d] com}
15
15
  s.extra_rdoc_files = [
@@ -75,7 +75,7 @@ Gem::Specification.new do |s|
75
75
  "tasks/yard.rake",
76
76
  "tasks/yardstick.rake"
77
77
  ]
78
- s.homepage = %q{http://github.com/datamapper/dm-more/tree/master/dm-migrations}
78
+ s.homepage = %q{http://github.com/datamapper/dm-migrations}
79
79
  s.rdoc_options = ["--charset=UTF-8"]
80
80
  s.require_paths = ["lib"]
81
81
  s.rubyforge_project = %q{datamapper}
@@ -107,14 +107,14 @@ Gem::Specification.new do |s|
107
107
  s.specification_version = 3
108
108
 
109
109
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
110
- s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
110
+ s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.0.rc3"])
111
111
  s.add_development_dependency(%q<rspec>, ["~> 1.3"])
112
112
  else
113
- s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
113
+ s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc3"])
114
114
  s.add_dependency(%q<rspec>, ["~> 1.3"])
115
115
  end
116
116
  else
117
- s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc2"])
117
+ s.add_dependency(%q<dm-core>, ["~> 1.0.0.rc3"])
118
118
  s.add_dependency(%q<rspec>, ["~> 1.3"])
119
119
  end
120
120
  end
@@ -154,6 +154,7 @@ module DataMapper
154
154
  def create_index_statements(model)
155
155
  name = self.name
156
156
  table_name = model.storage_name(name)
157
+
157
158
  indexes(model).map do |index_name, fields|
158
159
  <<-SQL.compress_lines
159
160
  CREATE INDEX #{quote_name("index_#{table_name}_#{index_name}")} ON
@@ -164,9 +165,12 @@ module DataMapper
164
165
 
165
166
  # @api private
166
167
  def create_unique_index_statements(model)
167
- name = self.name
168
- table_name = model.storage_name(name)
169
- unique_indexes(model).map do |index_name, fields|
168
+ name = self.name
169
+ table_name = model.storage_name(name)
170
+ key = model.key(name).map { |property| property.field }
171
+ unique_indexes = unique_indexes(model).reject { |index_name, fields| fields == key }
172
+
173
+ unique_indexes.map do |index_name, fields|
170
174
  <<-SQL.compress_lines
171
175
  CREATE UNIQUE INDEX #{quote_name("unique_#{table_name}_#{index_name}")} ON
172
176
  #{quote_name(table_name)} (#{fields.map { |field| quote_name(field) }.join(', ')})
@@ -181,12 +181,13 @@ module DataMapper
181
181
  end # module Model
182
182
 
183
183
  def self.include_migration_api
184
- DataMapper.extend(Migrations::SingletonMethods)
185
- DataMapper::Model.send(:include, Migrations::Model)
186
- DataMapper::Repository.send(:include, Migrations::Repository)
187
- DataMapper::Model.append_extensions(Migrations::Model)
188
- DataMapper::Repository.adapters.values.each do |adapter|
189
- Adapters.include_migration_api(ActiveSupport::Inflector.demodulize(adapter.class.name))
184
+ DataMapper.extend(SingletonMethods)
185
+ [ :Repository, :Model ].each do |name|
186
+ DataMapper.const_get(name).send(:include, const_get(name))
187
+ end
188
+ DataMapper::Model.append_extensions(Model)
189
+ Adapters::AbstractAdapter.descendants.each do |adapter_class|
190
+ Adapters.include_migration_api(ActiveSupport::Inflector.demodulize(adapter_class.name))
190
191
  end
191
192
  end
192
193
 
@@ -194,24 +195,22 @@ module DataMapper
194
195
 
195
196
  module Adapters
196
197
 
197
- extend Chainable
198
-
199
- class << self
200
-
201
- def include_migration_api(const_name)
202
- require auto_migration_extensions(const_name)
198
+ def self.include_migration_api(const_name)
199
+ require auto_migration_extensions(const_name)
200
+ if Migrations.const_defined?(const_name)
203
201
  adapter = const_get(const_name)
204
- if DataMapper::Migrations.const_defined?(const_name)
205
- adapter.send(:include, migration_module(const_name))
206
- end
207
- rescue LoadError
208
- # do nothing
202
+ adapter.send(:include, migration_module(const_name))
209
203
  end
204
+ rescue LoadError
205
+ # Silently ignore the fact that no adapter extensions could be required
206
+ # This means that the adapter in use doesn't support migrations
207
+ end
210
208
 
211
- def migration_module(const_name)
212
- DataMapper::Migrations.const_get(const_name)
213
- end
209
+ def self.migration_module(const_name)
210
+ Migrations.const_get(const_name)
211
+ end
214
212
 
213
+ class << self
215
214
  private
216
215
 
217
216
  # @api private
@@ -188,7 +188,7 @@ describe DataMapper::Migrations do
188
188
  end
189
189
 
190
190
  it 'should return true' do
191
- @response.should be_true
191
+ @response.should be(true)
192
192
  end
193
193
 
194
194
  it "should create a #{statement} column" do
@@ -236,7 +236,7 @@ describe DataMapper::Migrations do
236
236
  end
237
237
 
238
238
  it 'should return true' do
239
- @response.should be_true
239
+ @response.should be(true)
240
240
  end
241
241
 
242
242
  it "should create a #{statement} column" do
@@ -268,7 +268,7 @@ describe DataMapper::Migrations do
268
268
  end
269
269
 
270
270
  it 'should return true' do
271
- @response.should be_true
271
+ @response.should be(true)
272
272
  end
273
273
 
274
274
  it "should create a #{statement} column" do
@@ -331,7 +331,7 @@ describe DataMapper::Migrations do
331
331
  end
332
332
 
333
333
  it 'should return true' do
334
- @response.should be_true
334
+ @response.should be(true)
335
335
  end
336
336
 
337
337
  it "should create a #{statement} column" do
@@ -370,7 +370,7 @@ describe DataMapper::Migrations do
370
370
  end
371
371
 
372
372
  it 'should return true' do
373
- @response.should be_true
373
+ @response.should be(true)
374
374
  end
375
375
 
376
376
  it "should create a #{statement} column" do
@@ -411,7 +411,7 @@ describe DataMapper::Migrations do
411
411
  end
412
412
 
413
413
  it 'should return true' do
414
- @response.should be_true
414
+ @response.should be(true)
415
415
  end
416
416
 
417
417
  it "should create a #{statement} column" do
@@ -478,7 +478,7 @@ describe DataMapper::Migrations do
478
478
  end
479
479
 
480
480
  it 'should return true' do
481
- @response.should be_true
481
+ @response.should be(true)
482
482
  end
483
483
 
484
484
  it "should create a #{statement} column" do
@@ -120,12 +120,12 @@ describe "SQL generation" do
120
120
  end
121
121
 
122
122
  it "should know if the migration_info table exists" do
123
- @migration.send(:migration_info_table_exists?).should be_true
123
+ @migration.send(:migration_info_table_exists?).should be(true)
124
124
  end
125
125
 
126
126
  it "should know if the migration_info table does not exist" do
127
127
  DataMapper::Spec.adapter.execute("DROP TABLE migration_info") rescue nil
128
- @migration.send(:migration_info_table_exists?).should be_false
128
+ @migration.send(:migration_info_table_exists?).should be(false)
129
129
  end
130
130
 
131
131
  it "should be able to find the migration_info record for itself" do
@@ -134,15 +134,15 @@ describe "SQL generation" do
134
134
  end
135
135
 
136
136
  it "should know if a migration needs_up?" do
137
- @migration.send(:needs_up?).should be_true
137
+ @migration.send(:needs_up?).should be(true)
138
138
  insert_migration_record
139
- @migration.send(:needs_up?).should be_false
139
+ @migration.send(:needs_up?).should be(false)
140
140
  end
141
141
 
142
142
  it "should know if a migration needs_down?" do
143
- @migration.send(:needs_down?).should be_false
143
+ @migration.send(:needs_down?).should be(false)
144
144
  insert_migration_record
145
- @migration.send(:needs_down?).should be_true
145
+ @migration.send(:needs_down?).should be(true)
146
146
  end
147
147
 
148
148
  it "should properly quote the migration_info table via the adapter for use in queries" do
@@ -158,9 +158,9 @@ describe "SQL generation" do
158
158
 
159
159
  it "should create the migration_info table if it doesn't exist" do
160
160
  DataMapper::Spec.adapter.execute("DROP TABLE migration_info")
161
- @migration.send(:migration_info_table_exists?).should be_false
161
+ @migration.send(:migration_info_table_exists?).should be(false)
162
162
  @migration.send(:create_migration_info_table_if_needed)
163
- @migration.send(:migration_info_table_exists?).should be_true
163
+ @migration.send(:migration_info_table_exists?).should be(true)
164
164
  end
165
165
 
166
166
  it "should insert a record into the migration_info table on up" do
@@ -1,30 +1,30 @@
1
1
  require 'spec'
2
2
  require 'isolated/require_spec'
3
3
  require 'dm-core/spec/setup'
4
- require 'dm-core/spec/lib/adapter_helpers'
5
4
 
6
5
  # To really test this behavior, this spec needs to be run in isolation and not
7
6
  # as part of the typical rake spec run, which requires dm-transactions upfront
8
7
 
9
- describe "require 'dm-migrations' after calling DataMapper.setup" do
10
- extend DataMapper::Spec::Adapters::Helpers
8
+ if %w[ postgres mysql sqlite oracle sqlserver ].include?(ENV['ADAPTER'])
11
9
 
12
- before(:all) do
10
+ describe "require 'dm-migrations' after calling DataMapper.setup" do
13
11
 
14
- @adapter = DataMapper::Spec.adapter
15
- require 'dm-migrations'
12
+ before(:all) do
16
13
 
17
- class ::Person
18
- include DataMapper::Resource
19
- property :id, Serial
20
- end
14
+ @adapter = DataMapper::Spec.adapter
15
+ require 'dm-migrations'
21
16
 
22
- @model = Person
17
+ class ::Person
18
+ include DataMapper::Resource
19
+ property :id, Serial
20
+ end
23
21
 
24
- end
22
+ @model = Person
23
+
24
+ end
25
25
 
26
- supported_by :postgres, :mysql, :sqlite, :oracle, :sqlserver do
27
26
  it_should_behave_like "require 'dm-migrations'"
27
+
28
28
  end
29
29
 
30
30
  end
@@ -1,30 +1,30 @@
1
1
  require 'spec'
2
2
  require 'isolated/require_spec'
3
3
  require 'dm-core/spec/setup'
4
- require 'dm-core/spec/lib/adapter_helpers'
5
4
 
6
5
  # To really test this behavior, this spec needs to be run in isolation and not
7
6
  # as part of the typical rake spec run, which requires dm-transactions upfront
8
7
 
9
- describe "require 'dm-migrations' before calling DataMapper.setup" do
10
- extend DataMapper::Spec::Adapters::Helpers
8
+ if %w[ postgres mysql sqlite oracle sqlserver ].include?(ENV['ADAPTER'])
11
9
 
12
- before(:all) do
10
+ describe "require 'dm-migrations' before calling DataMapper.setup" do
13
11
 
14
- require 'dm-migrations'
15
- @adapter = DataMapper::Spec.adapter
12
+ before(:all) do
16
13
 
17
- class ::Person
18
- include DataMapper::Resource
19
- property :id, Serial
20
- end
14
+ require 'dm-migrations'
15
+ @adapter = DataMapper::Spec.adapter
21
16
 
22
- @model = Person
17
+ class ::Person
18
+ include DataMapper::Resource
19
+ property :id, Serial
20
+ end
23
21
 
24
- end
22
+ @model = Person
23
+
24
+ end
25
25
 
26
- supported_by :postgres, :mysql, :sqlite, :oracle, :sqlserver do
27
26
  it_should_behave_like "require 'dm-migrations'"
27
+
28
28
  end
29
29
 
30
30
  end
@@ -1,25 +1,25 @@
1
1
  shared_examples_for "require 'dm-migrations'" do
2
2
 
3
3
  it "should include the migration api in the DataMapper namespace" do
4
- DataMapper.respond_to?(:migrate! ).should be_true
5
- DataMapper.respond_to?(:auto_migrate! ).should be_true
6
- DataMapper.respond_to?(:auto_upgrade! ).should be_true
7
- DataMapper.respond_to?(:auto_migrate_up!, true).should be_true
8
- DataMapper.respond_to?(:auto_migrate_down!, true).should be_true
4
+ DataMapper.respond_to?(:migrate! ).should be(true)
5
+ DataMapper.respond_to?(:auto_migrate! ).should be(true)
6
+ DataMapper.respond_to?(:auto_upgrade! ).should be(true)
7
+ DataMapper.respond_to?(:auto_migrate_up!, true).should be(true)
8
+ DataMapper.respond_to?(:auto_migrate_down!, true).should be(true)
9
9
  end
10
10
 
11
- %w[Repository Model].each do |name|
11
+ %w[ Repository Model ].each do |name|
12
12
  it "should include the migration api in DataMapper::#{name}" do
13
- (DataMapper.const_get(name) < DataMapper::Migrations.const_get(name)).should be_true
13
+ (DataMapper.const_get(name) < DataMapper::Migrations.const_get(name)).should be(true)
14
14
  end
15
15
  end
16
16
 
17
17
  it "should include the migration api into the adapter" do
18
- @adapter.respond_to?(:storage_exists? ).should be_true
19
- @adapter.respond_to?(:field_exists? ).should be_true
20
- @adapter.respond_to?(:upgrade_model_storage).should be_true
21
- @adapter.respond_to?(:create_model_storage ).should be_true
22
- @adapter.respond_to?(:destroy_model_storage).should be_true
18
+ @adapter.respond_to?(:storage_exists? ).should be(true)
19
+ @adapter.respond_to?(:field_exists? ).should be(true)
20
+ @adapter.respond_to?(:upgrade_model_storage).should be(true)
21
+ @adapter.respond_to?(:create_model_storage ).should be(true)
22
+ @adapter.respond_to?(:destroy_model_storage).should be(true)
23
23
  end
24
24
 
25
25
  end
data/spec/rcov.opts CHANGED
@@ -1,4 +1,4 @@
1
- --exclude "spec"
1
+ --exclude "spec,^/"
2
2
  --sort coverage
3
3
  --callsites
4
4
  --xrefs
@@ -58,11 +58,11 @@ describe 'Migration' do
58
58
 
59
59
  it 'should set @verbose from the options hash' do
60
60
  m = DataMapper::Migration.new(1, :do_nothing, :verbose => false) {}
61
- m.instance_variable_get(:@verbose).should be_false
61
+ m.instance_variable_get(:@verbose).should be(false)
62
62
  end
63
63
 
64
64
  it 'should set @verbose to true by default' do
65
- @m.instance_variable_get(:@verbose).should be_true
65
+ @m.instance_variable_get(:@verbose).should be(true)
66
66
  end
67
67
 
68
68
  it 'should set the @up_action to an empty block' do
@@ -11,11 +11,11 @@ describe "Postgres Extensions" do
11
11
  end
12
12
 
13
13
  it 'should support schema-level transactions' do
14
- @pe.supports_schema_transactions?.should be_true
14
+ @pe.supports_schema_transactions?.should be(true)
15
15
  end
16
16
 
17
17
  it 'should support the serial column attribute' do
18
- @pe.supports_serial?.should be_true
18
+ @pe.supports_serial?.should be(true)
19
19
  end
20
20
 
21
21
  it 'should create a table object from the name' do
@@ -11,11 +11,11 @@ describe "SQLite3 Extensions" do
11
11
  end
12
12
 
13
13
  it 'should support schema-level transactions' do
14
- @se.supports_schema_transactions?.should be_true
14
+ @se.supports_schema_transactions?.should be(true)
15
15
  end
16
16
 
17
17
  it 'should support the serial column attribute' do
18
- @se.supports_serial?.should be_true
18
+ @se.supports_serial?.should be(true)
19
19
  end
20
20
 
21
21
  it 'should create a table object from the name' do
@@ -26,7 +26,7 @@ describe 'SQL module' do
26
26
  end
27
27
 
28
28
  it 'should evaluate the given block' do
29
- block = lambda { column :foo, :bar }
29
+ block = proc { column :foo, :bar }
30
30
  col = mock('column')
31
31
  SQL::TableCreator::Column.should_receive(:new).with(@adapter, :foo, :bar, {}).and_return(col)
32
32
  tc = SQL::TableCreator.new(@adapter, 'users', {}, &block)
@@ -26,7 +26,7 @@ describe 'SQL module' do
26
26
  end
27
27
 
28
28
  it 'should evaluate the given block' do
29
- block = lambda { column :foo, :bar }
29
+ block = proc { column :foo, :bar }
30
30
  col = mock('column')
31
31
  SQL::TableCreator::Column.should_receive(:new).with(@adapter, :foo, :bar, {}).and_return(col)
32
32
  tc = SQL::TableCreator.new(@adapter, 'users', {}, &block)
data/tasks/spec.rake CHANGED
@@ -35,4 +35,7 @@ rescue LoadError
35
35
  end
36
36
  end
37
37
 
38
+ task :spec => :check_dependencies
39
+ task :rcov => :check_dependencies
40
+
38
41
  task :default => :spec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dm-migrations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 977940575
4
+ hash: 977940572
5
5
  prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
9
  - 0
10
- - rc2
11
- version: 1.0.0.rc2
10
+ - rc3
11
+ version: 1.0.0.rc3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Paul Sadauskas
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-05-19 00:00:00 -07:00
19
+ date: 2010-05-27 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,13 +27,13 @@ dependencies:
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- hash: 977940575
30
+ hash: 977940572
31
31
  segments:
32
32
  - 1
33
33
  - 0
34
34
  - 0
35
- - rc2
36
- version: 1.0.0.rc2
35
+ - rc3
36
+ version: 1.0.0.rc3
37
37
  type: :runtime
38
38
  version_requirements: *id001
39
39
  - !ruby/object:Gem::Dependency
@@ -119,7 +119,7 @@ files:
119
119
  - tasks/yard.rake
120
120
  - tasks/yardstick.rake
121
121
  has_rdoc: true
122
- homepage: http://github.com/datamapper/dm-more/tree/master/dm-migrations
122
+ homepage: http://github.com/datamapper/dm-migrations
123
123
  licenses: []
124
124
 
125
125
  post_install_message: