db_nazi 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ef96777baa9820f3ac045b8d34c72186caaf3af8
4
+ data.tar.gz: 717b63040614818304ae8c8633948b1d1e796174
5
+ SHA512:
6
+ metadata.gz: 5d46ba3ebc5ed79e5cce094797e0bc58c7607be681b031f2c290580992531bf99c6c589f39354ff1cd5ee8e49227b38947e88707608de6269faf07a1cb657c5c
7
+ data.tar.gz: c6d3435923defc3b29aca0bf0f89a2a4799057d0260024386344cb55f3892c16fda864a3db1f96528f2177d901fb1274361c5828ce1c93bf184eb00227cb7147
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
+ /.bundle
1
2
  /Gemfile.lock
data/.travis.yml CHANGED
@@ -4,36 +4,35 @@ script: bundle exec rake ci
4
4
  rvm: [] # only run the builds in the matrix below
5
5
  matrix:
6
6
  include:
7
- - rvm: 1.9.2
7
+ - rvm: 1.9.3
8
8
  env: DB_NAZI_ADAPTER=sqlite3
9
- - rvm: 1.9.2
9
+ - rvm: 1.9.3
10
10
  env: DB_NAZI_ADAPTER=mysql
11
- - rvm: 1.9.2
11
+ - rvm: 1.9.3
12
12
  env: DB_NAZI_ADAPTER=mysql2
13
- - rvm: 1.9.2
13
+ - rvm: 1.9.3
14
14
  before_script: psql -c 'create database myapp_test;' -U postgres
15
15
  env: DB_NAZI_ADAPTER=postgresql
16
16
 
17
- - rvm: 1.9.3
17
+ - rvm: 2.1.0
18
18
  env: DB_NAZI_ADAPTER=sqlite3
19
- - rvm: 1.9.3
19
+ - rvm: 2.1.0
20
20
  env: DB_NAZI_ADAPTER=mysql
21
- - rvm: 1.9.3
21
+ - rvm: 2.1.0
22
22
  env: DB_NAZI_ADAPTER=mysql2
23
- - rvm: 1.9.3
23
+ - rvm: 2.1.0
24
24
  before_script: psql -c 'create database myapp_test;' -U postgres
25
25
  env: DB_NAZI_ADAPTER=postgresql
26
26
 
27
- - rvm: rbx-19mode
27
+ - rvm: rbx-2
28
28
  env: DB_NAZI_ADAPTER=sqlite3
29
- - rvm: rbx-19mode
29
+ - rvm: rbx-2
30
30
  env: DB_NAZI_ADAPTER=mysql
31
- - rvm: rbx-19mode
31
+ - rvm: rbx-2
32
32
  env: DB_NAZI_ADAPTER=mysql2
33
- - rvm: rbx-19mode
33
+ - rvm: rbx-2
34
34
  before_script: psql -c 'create database myapp_test;' -U postgres
35
35
  env: DB_NAZI_ADAPTER=postgresql
36
36
 
37
- # jruby-1.6.7 has a broken testrb - use head for now
38
- - rvm: jruby-head
37
+ - rvm: jruby-19mode
39
38
  env: DB_NAZI_ADAPTER=jdbcmysql
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.0.4 2014-02-14
2
+
3
+ * Rails 4 compatibility.
4
+
1
5
  == 0.0.3 2012-06-27
2
6
 
3
7
  * Disable DB Nazi when loading schema.
data/Gemfile CHANGED
@@ -1,4 +1,7 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
+ gem 'ritual'
3
+ gem 'minitest', '< 5'
4
+ gem 'temporaries'
2
5
  gemspec
3
6
 
4
7
  case ENV['DB_NAZI_ADAPTER']
data/README.markdown CHANGED
@@ -1,4 +1,4 @@
1
- ## DB Nazi
1
+ ## DB Nazi [![Build Status](https://travis-ci.org/oggy/db_nazi.png)](https://travis-ci.org/oggy/db_nazi)
2
2
 
3
3
  Encourages good DB practices in Active Record migrations.
4
4
 
data/db_nazi.gemspec CHANGED
@@ -16,8 +16,5 @@ Gem::Specification.new do |gem|
16
16
  gem.files = `git ls-files`.split("\n")
17
17
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
 
19
- gem.add_runtime_dependency 'activerecord', '~> 3.2.6'
20
- gem.add_development_dependency 'ritual', '~> 0.4.1'
21
- gem.add_development_dependency 'minitest', '~> 3.1.0'
22
- gem.add_development_dependency 'temporaries', '~> 0.3.0'
19
+ gem.add_runtime_dependency 'activerecord', '< 5'
23
20
  end
@@ -1,5 +1,5 @@
1
1
  module DBNazi
2
- VERSION = [0, 0, 3]
2
+ VERSION = [0, 0, 4]
3
3
 
4
4
  class << VERSION
5
5
  include Comparable
@@ -15,10 +15,6 @@ describe DBNazi do
15
15
  Dir.chdir @original_pwd
16
16
  end
17
17
 
18
- before do
19
- DBNazi.reset
20
- end
21
-
22
18
  it "raises an error when there is a careless migration" do
23
19
  create_bad_migration(1)
24
20
  run_migrations
data/test/test_helper.rb CHANGED
@@ -49,8 +49,11 @@ MiniTest::Spec.class_eval do
49
49
  end
50
50
 
51
51
  def self.use_database
52
- before { recreate_database }
53
- after { drop_database }
52
+ include Module.new {
53
+ extend MiniTest::Spec::DSL
54
+ before { recreate_database }
55
+ after { drop_database }
56
+ }
54
57
  end
55
58
 
56
59
  # Migrations use Kernel.puts. Lame. This shuts them up.
@@ -9,6 +9,11 @@ describe DBNazi::AbstractAdapter do
9
9
  end
10
10
 
11
11
  describe "#add_column" do
12
+ it "still adds the column if ok" do
13
+ connection.add_column 'test_table', 'test_column', :boolean, null: false, default: false
14
+ connection.column_exists?('test_table', 'test_column', :boolean, null: false, default: false).must_equal true
15
+ end
16
+
12
17
  describe "when nullability is required" do
13
18
  use_attribute_value DBNazi, :require_nullability, true
14
19
 
@@ -63,6 +68,11 @@ describe DBNazi::AbstractAdapter do
63
68
  connection.add_column 'test_table', 'test_column', :boolean, null: false, default: false
64
69
  end
65
70
 
71
+ it "still changes the column if ok" do
72
+ connection.change_column 'test_table', 'test_column', :boolean, null: true
73
+ connection.column_exists?('test_table', 'test_column', :boolean, null: true).must_equal true
74
+ end
75
+
66
76
  describe "when nullability is required" do
67
77
  use_attribute_value DBNazi, :require_nullability, true
68
78
 
@@ -117,6 +127,11 @@ describe DBNazi::AbstractAdapter do
117
127
  connection.add_column 'test_table', 'test_column', :boolean, null: true
118
128
  end
119
129
 
130
+ it "still adds the index if ok" do
131
+ connection.add_index 'test_table', 'test_column', unique: false
132
+ connection.index_exists?('test_table', 'test_column').must_equal true
133
+ end
134
+
120
135
  describe "when index uniqueness is required" do
121
136
  use_attribute_value DBNazi, :require_index_uniqueness, true
122
137
 
@@ -8,13 +8,7 @@ describe DBNazi::MigrationProxy do
8
8
  before do
9
9
  @original_pwd = Dir.pwd
10
10
  Dir.chdir "#{ROOT}/test/tmp"
11
- end
12
-
13
- after do
14
- Dir.chdir @original_pwd
15
- end
16
11
 
17
- before do
18
12
  @migration_proxy = ActiveRecord::MigrationProxy.new("test_migration", 10, "test_migration.rb", nil)
19
13
  @migration_class = Class.new(ActiveRecord::Migration) do
20
14
  attr_reader :enabled
@@ -27,6 +21,10 @@ describe DBNazi::MigrationProxy do
27
21
  @migration_proxy.singleton_class.send(:define_method, :migration) { migration }
28
22
  end
29
23
 
24
+ after do
25
+ Dir.chdir @original_pwd
26
+ end
27
+
30
28
  describe "#migrate" do
31
29
  it "disables DBNazi when no_nazi is used" do
32
30
  @migration_class.no_nazi
@@ -12,6 +12,13 @@ describe DBNazi::TableDefinition do
12
12
  connection.create_table 'test_table'
13
13
  end
14
14
 
15
+ it "still creates the column if ok" do
16
+ connection.change_table 'test_table', bulk: true do |t|
17
+ t.column 'test_column', :boolean, null: true
18
+ end
19
+ connection.column_exists?('test_table', 'test_column', :boolean, null: true).must_equal true
20
+ end
21
+
15
22
  describe "when nullability is required" do
16
23
  use_attribute_value DBNazi, :require_nullability, true
17
24
 
@@ -82,6 +89,13 @@ describe DBNazi::TableDefinition do
82
89
  end
83
90
  end
84
91
 
92
+ it "still creates the index if ok" do
93
+ connection.change_table 'test_table', bulk: true do |t|
94
+ t.index 'test_column', unique: false
95
+ end
96
+ connection.index_exists?('test_table', 'test_column', unique: false).must_equal true
97
+ end
98
+
85
99
  describe "when index uniqueness is required" do
86
100
  use_attribute_value DBNazi, :require_index_uniqueness, true
87
101
 
@@ -124,6 +138,13 @@ describe DBNazi::TableDefinition do
124
138
  end
125
139
  end
126
140
 
141
+ it "still changes the column if ok" do
142
+ connection.change_table 'test_table', bulk: true do |t|
143
+ t.change 'test_column', :boolean, null: false, default: false
144
+ end
145
+ connection.column_exists?('test_table', 'test_column', :boolean, null: false, default: false).must_equal true
146
+ end
147
+
127
148
  describe "when nullability is required" do
128
149
  use_attribute_value DBNazi, :require_nullability, true
129
150
 
@@ -8,6 +8,13 @@ describe DBNazi::TableDefinition do
8
8
  end
9
9
 
10
10
  describe "#column" do
11
+ it "still creates the column if ok" do
12
+ connection.create_table 'test_table' do |t|
13
+ t.column 'test_column', :boolean, null: true
14
+ end
15
+ connection.column_exists?('test_table', 'test_column', :boolean, null: true).must_equal true
16
+ end
17
+
11
18
  describe "when nullability is required" do
12
19
  use_attribute_value DBNazi, :require_nullability, true
13
20
 
metadata CHANGED
@@ -1,80 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_nazi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - George Ogata
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-06-27 00:00:00.000000000 Z
11
+ date: 2014-02-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "<"
20
18
  - !ruby/object:Gem::Version
21
- version: 3.2.6
19
+ version: '5'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "<"
28
25
  - !ruby/object:Gem::Version
29
- version: 3.2.6
30
- - !ruby/object:Gem::Dependency
31
- name: ritual
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 0.4.1
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 0.4.1
46
- - !ruby/object:Gem::Dependency
47
- name: minitest
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: 3.1.0
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: 3.1.0
62
- - !ruby/object:Gem::Dependency
63
- name: temporaries
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: 0.3.0
70
- type: :development
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ~>
76
- - !ruby/object:Gem::Version
77
- version: 0.3.0
26
+ version: '5'
78
27
  description: ''
79
28
  email:
80
29
  - george.ogata@gmail.com
@@ -82,8 +31,8 @@ executables: []
82
31
  extensions: []
83
32
  extra_rdoc_files: []
84
33
  files:
85
- - .gitignore
86
- - .travis.yml
34
+ - ".gitignore"
35
+ - ".travis.yml"
87
36
  - CHANGELOG
88
37
  - Gemfile
89
38
  - LICENSE
@@ -111,33 +60,26 @@ files:
111
60
  homepage: ''
112
61
  licenses:
113
62
  - MIT
63
+ metadata: {}
114
64
  post_install_message:
115
65
  rdoc_options: []
116
66
  require_paths:
117
67
  - lib
118
68
  required_ruby_version: !ruby/object:Gem::Requirement
119
- none: false
120
69
  requirements:
121
- - - ! '>='
70
+ - - ">="
122
71
  - !ruby/object:Gem::Version
123
72
  version: '0'
124
- segments:
125
- - 0
126
- hash: -2333184105652215530
127
73
  required_rubygems_version: !ruby/object:Gem::Requirement
128
- none: false
129
74
  requirements:
130
- - - ! '>='
75
+ - - ">="
131
76
  - !ruby/object:Gem::Version
132
77
  version: '0'
133
- segments:
134
- - 0
135
- hash: -2333184105652215530
136
78
  requirements: []
137
79
  rubyforge_project:
138
- rubygems_version: 1.8.24
80
+ rubygems_version: 2.2.0
139
81
  signing_key:
140
- specification_version: 3
82
+ specification_version: 4
141
83
  summary: Encourage good DB practices in ActiveRecord migrations.
142
84
  test_files:
143
85
  - test/database.yml