migration_comments 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +10 -7
- data/lib/migration_comments/active_record/connection_adapters/mysql_adapter.rb +1 -1
- data/lib/migration_comments/active_record/connection_adapters/postgresql_adapter.rb +2 -2
- data/lib/migration_comments/version.rb +1 -1
- data/migration_comments.gemspec +3 -2
- data/test/schema_dumper_test.rb +1 -12
- data/test/test_helper.rb +3 -1
- metadata +5 -12
data/README.rdoc
CHANGED
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
Comments for your migrations
|
4
4
|
|
5
|
-
Tested on
|
5
|
+
Tested on:
|
6
|
+
|
7
|
+
Ruby 1.8.7 using Rails 3.x
|
8
|
+
Ruby 1.8.6 using Rails 2.3.x.
|
6
9
|
|
7
10
|
== Why?
|
8
11
|
|
@@ -26,9 +29,9 @@ file.
|
|
26
29
|
|
27
30
|
== Examples
|
28
31
|
|
29
|
-
|
32
|
+
To add a comment to an existing structure...
|
30
33
|
|
31
|
-
self.up
|
34
|
+
def self.up
|
32
35
|
add_table_comment :table_name, "A table comment"
|
33
36
|
comment_table :table_name, "A table comment" # does the same thing
|
34
37
|
|
@@ -38,7 +41,7 @@ Want to add a comment to an existing structure...
|
|
38
41
|
|
39
42
|
Or you can use the change_table macro...
|
40
43
|
|
41
|
-
self.up
|
44
|
+
def self.up
|
42
45
|
change_table :table_name do |t|
|
43
46
|
t.comment "A table comment"
|
44
47
|
t.change_comment :column_name, "A column comment"
|
@@ -47,7 +50,7 @@ Or you can use the change_table macro...
|
|
47
50
|
|
48
51
|
Creating a new table?
|
49
52
|
|
50
|
-
self.up
|
53
|
+
def self.up
|
51
54
|
create_table :table_name, :comment => "A table comment" do |t|
|
52
55
|
t.string :column_name, :comment => "A column comment"
|
53
56
|
end
|
@@ -55,14 +58,14 @@ Creating a new table?
|
|
55
58
|
|
56
59
|
You can also remove comments...
|
57
60
|
|
58
|
-
self.up
|
61
|
+
def self.up
|
59
62
|
remove_table_comment :table_name
|
60
63
|
remove_column_comment :table_name, :column_name
|
61
64
|
end
|
62
65
|
|
63
66
|
Or you can combine these commands while modifying a table...
|
64
67
|
|
65
|
-
self.up
|
68
|
+
def self.up
|
66
69
|
change_table :existing_table do |t|
|
67
70
|
t.comment nil # remove an existing table comment
|
68
71
|
t.string :new_column, :comment => "a new column" # add a new column with a comment
|
@@ -23,12 +23,12 @@ module MigrationComments::ActiveRecord::ConnectionAdapters
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def retrieve_table_comment(table_name)
|
26
|
-
result =
|
26
|
+
result = select_rows(table_comment_sql(table_name))
|
27
27
|
result[0].nil? ? nil : result[0][0]
|
28
28
|
end
|
29
29
|
|
30
30
|
def retrieve_column_comments(table_name, *column_names)
|
31
|
-
result =
|
31
|
+
result = select_rows(column_comment_sql(table_name, *column_names))
|
32
32
|
return {} if result.nil?
|
33
33
|
return result.inject({}){|m, row| m[row[0].to_sym] = row[1]; m}
|
34
34
|
end
|
data/migration_comments.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
s.add_runtime_dependency 'rails', '
|
21
|
+
s.add_runtime_dependency 'rails', '>= 2.3.2'
|
22
22
|
|
23
23
|
# for development, we are testing against the 'annotate' gem
|
24
24
|
# however, the comments should work with the original 'annotate_models' plugin as well at:
|
@@ -26,7 +26,8 @@ Gem::Specification.new do |s|
|
|
26
26
|
# provided the environment is not loaded until _after_ the AnnotateModels module is declared
|
27
27
|
s.add_development_dependency 'annotate'
|
28
28
|
|
29
|
-
s.add_development_dependency '
|
29
|
+
s.add_development_dependency 'pg' # replace with other adapter as needed
|
30
|
+
# s.add_development_dependency 'postgres-pr'
|
30
31
|
# s.add_development_dependency 'mysql'
|
31
32
|
# s.add_development_dependency 'mysql2'
|
32
33
|
end
|
data/test/schema_dumper_test.rb
CHANGED
@@ -14,17 +14,6 @@ class SchemaDumperTest < Test::Unit::TestCase
|
|
14
14
|
dest.rewind
|
15
15
|
result = dest.read
|
16
16
|
expected = <<EOS
|
17
|
-
# This file is auto-generated from the current state of the database. Instead of editing this file,
|
18
|
-
# please use the migrations feature of Active Record to incrementally modify your database, and
|
19
|
-
# then regenerate this schema definition.
|
20
|
-
#
|
21
|
-
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
|
22
|
-
# to create the application database on another system, you should be using db:schema:load, not running
|
23
|
-
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
24
|
-
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
25
|
-
#
|
26
|
-
# It's strongly recommended to check this file into your version control system.
|
27
|
-
|
28
17
|
ActiveRecord::Schema.define(:version => 1) do
|
29
18
|
|
30
19
|
create_table "sample", :force => true, :comment => "a table comment" do |t|
|
@@ -35,6 +24,6 @@ ActiveRecord::Schema.define(:version => 1) do
|
|
35
24
|
|
36
25
|
end
|
37
26
|
EOS
|
38
|
-
|
27
|
+
assert_match /#{Regexp.escape expected}/, result
|
39
28
|
end
|
40
29
|
end
|
data/test/test_helper.rb
CHANGED
@@ -7,7 +7,9 @@ require 'yaml'
|
|
7
7
|
|
8
8
|
CONFIGURATIONS = YAML::load(IO.read('config/database.yml'))
|
9
9
|
|
10
|
-
|
10
|
+
ENV['DB'] ||= 'postgres' # override as needed
|
11
|
+
|
12
|
+
ActiveRecord::Base.establish_connection(CONFIGURATIONS[ENV['DB']])
|
11
13
|
|
12
14
|
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
13
15
|
require 'migration_comments'
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: migration_comments
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Pinny
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-02-
|
18
|
+
date: 2012-02-13 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -24,13 +24,6 @@ dependencies:
|
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 5
|
30
|
-
segments:
|
31
|
-
- 2
|
32
|
-
- 3
|
33
|
-
version: "2.3"
|
34
27
|
- - ">="
|
35
28
|
- !ruby/object:Gem::Version
|
36
29
|
hash: 7
|
@@ -56,7 +49,7 @@ dependencies:
|
|
56
49
|
type: :development
|
57
50
|
version_requirements: *id002
|
58
51
|
- !ruby/object:Gem::Dependency
|
59
|
-
name:
|
52
|
+
name: pg
|
60
53
|
prerelease: false
|
61
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
62
55
|
none: false
|