ridgepole 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74af55adebfffcd9880e5a0fde3e2eee3fc2c75d
|
4
|
+
data.tar.gz: 1b3255a9a2c1b29b3980b32739a55b83100542c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83ae32148265a558bb781c2eadf4cc3b988d2a4380fb66be2e7e13163b239e7ea1c3d1a4136f3d7149ede683338dc0fb2b0e8ced5c8d3b460fd4d9647bb10fe0
|
7
|
+
data.tar.gz: 9099196ec666a10f7da892c3af21302e654c0801516815e1a888eec86a034d649cfe4eb940cd8ffafa0cd457c08b63657a1cf05621a57793ee78773143a31a42
|
data/lib/ridgepole/dsl_parser.rb
CHANGED
@@ -8,6 +8,8 @@ class Ridgepole::DSLParser
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def column(name, type, options = {})
|
11
|
+
name = name.to_s
|
12
|
+
|
11
13
|
@__definition[name] = {
|
12
14
|
:type => type,
|
13
15
|
:options => options,
|
@@ -57,7 +59,13 @@ class Ridgepole::DSLParser
|
|
57
59
|
end
|
58
60
|
|
59
61
|
def create_table(table_name, options = {})
|
62
|
+
table_name = table_name.to_s
|
60
63
|
table_definition = TableDefinition.new
|
64
|
+
|
65
|
+
[:primary_key].each do |key|
|
66
|
+
options[key] = options[key].to_s if options[key]
|
67
|
+
end
|
68
|
+
|
61
69
|
yield(table_definition)
|
62
70
|
@__definition[table_name] ||= {}
|
63
71
|
|
@@ -71,6 +79,9 @@ class Ridgepole::DSLParser
|
|
71
79
|
end
|
72
80
|
|
73
81
|
def add_index(table_name, column_name, options = {})
|
82
|
+
table_name = table_name.to_s
|
83
|
+
column_name = [column_name].flatten.map {|i| i.to_s }
|
84
|
+
options[:name] = options[:name].to_s if options[:name]
|
74
85
|
@__definition[table_name] ||= {}
|
75
86
|
@__definition[table_name][:indices] ||= {}
|
76
87
|
idx = options[:name] || column_name
|
data/lib/ridgepole/version.rb
CHANGED
@@ -0,0 +1,94 @@
|
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
+
context 'when change column (no change)' do
|
3
|
+
let(:actual_dsl) {
|
4
|
+
<<-RUBY
|
5
|
+
create_table "employees", primary_key: "emp_no", force: true do |t|
|
6
|
+
t.date "birth_date", null: false
|
7
|
+
t.string "first_name", limit: 14, null: false
|
8
|
+
t.string "last_name", limit: 16, null: false
|
9
|
+
t.string "gender", limit: 1, null: false
|
10
|
+
t.date "hire_date", null: false
|
11
|
+
end
|
12
|
+
|
13
|
+
add_index "employees", ["gender"], name: "gender", using: :btree
|
14
|
+
RUBY
|
15
|
+
}
|
16
|
+
|
17
|
+
let(:expected_dsl) {
|
18
|
+
<<-RUBY
|
19
|
+
create_table :employees, primary_key: :emp_no, force: true do |t|
|
20
|
+
t.date "birth_date", null: false
|
21
|
+
t.string "first_name", limit: 14, null: false
|
22
|
+
t.string "last_name", limit: 16, null: false
|
23
|
+
t.string "gender", limit: 1, null: false
|
24
|
+
t.date :hire_date, null: false
|
25
|
+
end
|
26
|
+
|
27
|
+
add_index :employees, :gender, name: :gender, using: :btree
|
28
|
+
RUBY
|
29
|
+
}
|
30
|
+
|
31
|
+
before { subject.diff(actual_dsl).migrate }
|
32
|
+
subject { client }
|
33
|
+
|
34
|
+
it {
|
35
|
+
delta = subject.diff(expected_dsl)
|
36
|
+
expect(delta.differ?).to be_falsey
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'when change column (change)' do
|
41
|
+
let(:actual_dsl) {
|
42
|
+
<<-RUBY
|
43
|
+
create_table "employees", primary_key: "emp_no", force: true do |t|
|
44
|
+
t.date "birth_date", null: false
|
45
|
+
t.string "first_name", limit: 14, null: false
|
46
|
+
t.string "last_name", limit: 16, null: false
|
47
|
+
t.string "gender", limit: 1, null: false
|
48
|
+
t.date "hire_date", null: false
|
49
|
+
end
|
50
|
+
|
51
|
+
add_index "employees", ["gender"], name: "gender", using: :btree
|
52
|
+
RUBY
|
53
|
+
}
|
54
|
+
|
55
|
+
let(:dsl) {
|
56
|
+
<<-RUBY
|
57
|
+
create_table :employees, primary_key: :emp_no, force: true do |t|
|
58
|
+
t.date "birth_date", null: false
|
59
|
+
t.string "first_name", limit: 14, null: false
|
60
|
+
t.string "last_name", limit: 16, null: false
|
61
|
+
t.string "gender", limit: 1, null: false
|
62
|
+
t.date :hire_date2, null: false
|
63
|
+
end
|
64
|
+
|
65
|
+
add_index :employees, :last_name, name: :last_name, using: :btree
|
66
|
+
RUBY
|
67
|
+
}
|
68
|
+
|
69
|
+
let(:expected_dsl) {
|
70
|
+
<<-RUBY
|
71
|
+
create_table "employees", primary_key: "emp_no", force: true do |t|
|
72
|
+
t.date "birth_date", null: false
|
73
|
+
t.string "first_name", limit: 14, null: false
|
74
|
+
t.string "last_name", limit: 16, null: false
|
75
|
+
t.string "gender", limit: 1, null: false
|
76
|
+
t.date "hire_date2", null: false
|
77
|
+
end
|
78
|
+
|
79
|
+
add_index "employees", ["last_name"], name: "last_name", using: :btree
|
80
|
+
RUBY
|
81
|
+
}
|
82
|
+
|
83
|
+
before { subject.diff(actual_dsl).migrate }
|
84
|
+
subject { client }
|
85
|
+
|
86
|
+
it {
|
87
|
+
delta = subject.diff(dsl)
|
88
|
+
expect(delta.differ?).to be_truthy
|
89
|
+
expect(subject.dump).to eq actual_dsl.strip_heredoc.strip
|
90
|
+
delta.migrate
|
91
|
+
expect(subject.dump).to eq expected_dsl.strip_heredoc.strip.gsub(/(\s*,\s*unsigned: false)?\s*,\s*null: true/, '')
|
92
|
+
}
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
describe 'Ridgepole::Client#diff -> migrate' do
|
2
|
+
context 'when change index (no change)' do
|
3
|
+
let(:actual_dsl) {
|
4
|
+
<<-RUBY
|
5
|
+
create_table "salaries", id: false, force: true do |t|
|
6
|
+
t.integer "emp_no", null: false
|
7
|
+
t.integer "salary", null: false
|
8
|
+
t.date "from_date", null: false
|
9
|
+
t.date "to_date", null: false
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
13
|
+
RUBY
|
14
|
+
}
|
15
|
+
|
16
|
+
let(:expected_dsl) {
|
17
|
+
<<-RUBY
|
18
|
+
create_table "salaries", id: false, force: true do |t|
|
19
|
+
t.integer "emp_no", null: false
|
20
|
+
t.integer "salary", null: false
|
21
|
+
t.date "from_date", null: false
|
22
|
+
t.date "to_date", null: false
|
23
|
+
end
|
24
|
+
|
25
|
+
add_index "salaries", "emp_no", name: "emp_no", using: :btree
|
26
|
+
RUBY
|
27
|
+
}
|
28
|
+
|
29
|
+
before { subject.diff(actual_dsl).migrate }
|
30
|
+
subject { client }
|
31
|
+
|
32
|
+
it {
|
33
|
+
delta = subject.diff(expected_dsl)
|
34
|
+
expect(delta.differ?).to be_falsey
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when change index (change)' do
|
39
|
+
let(:actual_dsl) {
|
40
|
+
<<-RUBY
|
41
|
+
create_table "salaries", id: false, force: true do |t|
|
42
|
+
t.integer "emp_no", null: false
|
43
|
+
t.integer "salary", null: false
|
44
|
+
t.date "from_date", null: false
|
45
|
+
t.date "to_date", null: false
|
46
|
+
end
|
47
|
+
|
48
|
+
add_index "salaries", ["emp_no"], name: "emp_no", using: :btree
|
49
|
+
RUBY
|
50
|
+
}
|
51
|
+
|
52
|
+
let(:dsl) {
|
53
|
+
<<-RUBY
|
54
|
+
create_table "salaries", id: false, force: true do |t|
|
55
|
+
t.integer "emp_no", null: false
|
56
|
+
t.integer "salary", null: false
|
57
|
+
t.date "from_date", null: false
|
58
|
+
t.date "to_date", null: false
|
59
|
+
end
|
60
|
+
|
61
|
+
add_index "salaries", "salary", name: "emp_no", using: :btree
|
62
|
+
RUBY
|
63
|
+
}
|
64
|
+
|
65
|
+
let(:expected_dsl) {
|
66
|
+
<<-RUBY
|
67
|
+
create_table "salaries", id: false, force: true do |t|
|
68
|
+
t.integer "emp_no", null: false
|
69
|
+
t.integer "salary", null: false
|
70
|
+
t.date "from_date", null: false
|
71
|
+
t.date "to_date", null: false
|
72
|
+
end
|
73
|
+
|
74
|
+
add_index "salaries", ["salary"], name: "emp_no", using: :btree
|
75
|
+
RUBY
|
76
|
+
}
|
77
|
+
|
78
|
+
before { subject.diff(actual_dsl).migrate }
|
79
|
+
subject { client }
|
80
|
+
|
81
|
+
it {
|
82
|
+
delta = subject.diff(dsl)
|
83
|
+
expect(delta.differ?).to be_truthy
|
84
|
+
expect(subject.dump.delete_empty_lines).to eq actual_dsl.strip_heredoc.strip.delete_empty_lines
|
85
|
+
delta.migrate
|
86
|
+
expect(subject.dump.delete_empty_lines).to eq expected_dsl.strip_heredoc.strip.delete_empty_lines
|
87
|
+
}
|
88
|
+
end
|
89
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ridgepole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -130,7 +130,9 @@ files:
|
|
130
130
|
- spec/dump/dump_spec.rb
|
131
131
|
- spec/migrate/check_orphan_index_spec.rb
|
132
132
|
- spec/migrate/migrate_add_column_spec.rb
|
133
|
+
- spec/migrate/migrate_change_column2_spec.rb
|
133
134
|
- spec/migrate/migrate_change_column_spec.rb
|
135
|
+
- spec/migrate/migrate_change_index2_spec.rb
|
134
136
|
- spec/migrate/migrate_change_index_spec.rb
|
135
137
|
- spec/migrate/migrate_change_table_option_spec.rb
|
136
138
|
- spec/migrate/migrate_create_index_spec.rb
|
@@ -181,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
183
|
version: '0'
|
182
184
|
requirements: []
|
183
185
|
rubyforge_project:
|
184
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.4.1
|
185
187
|
signing_key:
|
186
188
|
specification_version: 4
|
187
189
|
summary: Ridgepole is a tool to DB schema.
|
@@ -193,7 +195,9 @@ test_files:
|
|
193
195
|
- spec/dump/dump_spec.rb
|
194
196
|
- spec/migrate/check_orphan_index_spec.rb
|
195
197
|
- spec/migrate/migrate_add_column_spec.rb
|
198
|
+
- spec/migrate/migrate_change_column2_spec.rb
|
196
199
|
- spec/migrate/migrate_change_column_spec.rb
|
200
|
+
- spec/migrate/migrate_change_index2_spec.rb
|
197
201
|
- spec/migrate/migrate_change_index_spec.rb
|
198
202
|
- spec/migrate/migrate_change_table_option_spec.rb
|
199
203
|
- spec/migrate/migrate_create_index_spec.rb
|