migration_comments 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -32,7 +32,7 @@ module MigrationComments::ActiveRecord
|
|
32
32
|
end
|
33
33
|
lines << content
|
34
34
|
end
|
35
|
-
len = col_names.keys.map{|index| lines[index]}.map(&:length).max + 2
|
35
|
+
len = col_names.keys.map{|index| lines[index]}.map(&:length).max + 2 unless col_names.empty?
|
36
36
|
lines.each_with_index do |line, index|
|
37
37
|
if table_line == index && table_comment.present?
|
38
38
|
block_init = " do |t|"
|
data/lib/migration_comments.rb
CHANGED
@@ -12,6 +12,8 @@ require 'migration_comments/active_record/connection_adapters/mysql2_adapter'
|
|
12
12
|
require 'migration_comments/active_record/connection_adapters/postgresql_adapter'
|
13
13
|
require 'migration_comments/active_record/connection_adapters/sqlite_adapter'
|
14
14
|
|
15
|
+
require 'active_record/connection_adapters/abstract_adapter'
|
16
|
+
|
15
17
|
module MigrationComments
|
16
18
|
def self.setup
|
17
19
|
base_names = %w(SchemaDumper) +
|
data/test/schema_dumper_test.rb
CHANGED
@@ -4,10 +4,7 @@ class SchemaDumperTest < Test::Unit::TestCase
|
|
4
4
|
include TestHelper
|
5
5
|
|
6
6
|
def test_dump
|
7
|
-
db_type = :default
|
8
7
|
ActiveRecord::Schema.define do
|
9
|
-
db_type = :sqlite if connection.is_a?(ActiveRecord::ConnectionAdapters::SQLiteAdapter) rescue false
|
10
|
-
|
11
8
|
set_table_comment :sample, "a table comment"
|
12
9
|
set_column_comment :sample, :field1, "a \"comment\" \\ that ' needs; escaping''"
|
13
10
|
add_column :sample, :field3, :string, :null => false, :default => "", :comment => "third column comment"
|
@@ -25,6 +22,27 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
25
22
|
t.string "field3", :default => "", :null => false, :comment => "third column comment"
|
26
23
|
end
|
27
24
|
|
25
|
+
end
|
26
|
+
EOS
|
27
|
+
|
28
|
+
assert_match /#{Regexp.escape expected}/, result
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_dump_with_no_columns
|
32
|
+
ActiveRecord::Schema.define do
|
33
|
+
remove_column :sample, :field1, :field2
|
34
|
+
set_table_comment :sample, "a table comment"
|
35
|
+
end
|
36
|
+
dest = StringIO.new
|
37
|
+
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, dest)
|
38
|
+
dest.rewind
|
39
|
+
result = dest.read
|
40
|
+
expected = <<EOS
|
41
|
+
ActiveRecord::Schema.define(:version => 1) do
|
42
|
+
|
43
|
+
create_table "sample", :force => true, :comment => "a table comment" do |t|
|
44
|
+
end
|
45
|
+
|
28
46
|
end
|
29
47
|
EOS
|
30
48
|
|
metadata
CHANGED
@@ -1,72 +1,79 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: migration_comments
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 1
|
10
|
+
version: 0.2.1
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Pinny
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-12-31 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
15
22
|
name: rails
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: 2.3.2
|
22
|
-
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 3
|
33
|
+
- 2
|
29
34
|
version: 2.3.2
|
30
|
-
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
31
38
|
name: annotate
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 2.5.0
|
38
|
-
type: :development
|
39
39
|
prerelease: false
|
40
|
-
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
|
-
requirements:
|
42
|
+
requirements:
|
43
43
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 27
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 5
|
49
|
+
- 0
|
45
50
|
version: 2.5.0
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: pg
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
|
-
requirements:
|
51
|
-
- - ! '>='
|
52
|
-
- !ruby/object:Gem::Version
|
53
|
-
version: '0'
|
54
51
|
type: :development
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: pg
|
55
55
|
prerelease: false
|
56
|
-
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
57
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 3
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
version: "0"
|
65
|
+
type: :development
|
66
|
+
version_requirements: *id003
|
67
|
+
description: Add schema comments in your migrations, see them in model annotations and db/schema.rb dump
|
68
|
+
email:
|
65
69
|
- pinny@medwiztech.com
|
66
70
|
executables: []
|
71
|
+
|
67
72
|
extensions: []
|
73
|
+
|
68
74
|
extra_rdoc_files: []
|
69
|
-
|
75
|
+
|
76
|
+
files:
|
70
77
|
- .gitignore
|
71
78
|
- Gemfile
|
72
79
|
- MIT-LICENSE
|
@@ -93,28 +100,39 @@ files:
|
|
93
100
|
- test/config/database.yml
|
94
101
|
- test/schema_dumper_test.rb
|
95
102
|
- test/test_helper.rb
|
103
|
+
has_rdoc: true
|
96
104
|
homepage: https://github.com/pinnymz/migration_comments
|
97
105
|
licenses: []
|
106
|
+
|
98
107
|
post_install_message:
|
99
108
|
rdoc_options: []
|
100
|
-
|
109
|
+
|
110
|
+
require_paths:
|
101
111
|
- lib
|
102
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
113
|
none: false
|
104
|
-
requirements:
|
105
|
-
- -
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
|
108
|
-
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
hash: 3
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
version: "0"
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
122
|
none: false
|
110
|
-
requirements:
|
111
|
-
- -
|
112
|
-
- !ruby/object:Gem::Version
|
113
|
-
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
hash: 3
|
127
|
+
segments:
|
128
|
+
- 0
|
129
|
+
version: "0"
|
114
130
|
requirements: []
|
131
|
+
|
115
132
|
rubyforge_project: migration_comments
|
116
|
-
rubygems_version: 1.
|
133
|
+
rubygems_version: 1.3.7
|
117
134
|
signing_key:
|
118
135
|
specification_version: 3
|
119
136
|
summary: Comments for your migrations
|
120
137
|
test_files: []
|
138
|
+
|