convergence 0.2.5 → 0.2.6
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +19 -16
- data/lib/convergence/command.rb +3 -1
- data/lib/convergence/dumper.rb +5 -5
- data/lib/convergence/sql_generator/mysql_generator.rb +2 -1
- data/lib/convergence/version.rb +1 -1
- data/spec/convergence/dumper_spec.rb +30 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 791c3a30d2bc49635b6e63fe9d137e9d20a99236
|
4
|
+
data.tar.gz: c21c2f48ea674ee79308257165b5c57111b7f638
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f3c65613fe2ace2c270e8462d8b0b369aa177fb9c99ccaf21dbf31c5b5bfe7033b40dc30bc9cccb9a9eaf8eca46e0be2adb2fbd60f115fafc9697058f3d5ef2
|
7
|
+
data.tar.gz: 951a2df0c366c648462aaabd6b65d284f04b3374c4d057bacc1d1e409d22e2012b7525c9c50d2d1d1f19f8d4519f714b39665530df86f67a4915affac720408a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## Convergence 0.2.6 (March 4, 2018) ##
|
2
|
+
|
3
|
+
* Improve dryrun output (PR: #55)
|
4
|
+
|
5
|
+
*yujideveloper*
|
6
|
+
|
7
|
+
* Support MySQL identifiers that require quotes in Ruby symbol syntax on export dsl (PR: #56)
|
8
|
+
|
9
|
+
*yujideveloper*
|
10
|
+
|
11
|
+
* Output help message when executed without option (PR: #57)
|
12
|
+
|
13
|
+
*yujideveloper*
|
14
|
+
|
1
15
|
## Convergence 0.2.5 (December 21, 2017) ##
|
2
16
|
|
3
17
|
* Bug Fix Diff option does not work fine (PR: #50)
|
data/Gemfile.lock
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -55,8 +55,6 @@ end
|
|
55
55
|
|
56
56
|
$ convergence -c database.yml -i example.schema --dryrun
|
57
57
|
|
58
|
-
#
|
59
|
-
#
|
60
58
|
# CREATE TABLE `test_tables` (
|
61
59
|
# `id` int(11) NOT NULL AUTO_INCREMENT,
|
62
60
|
# `name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
|
@@ -69,7 +67,7 @@ $ convergence -c database.yml -i example.schema --dryrun
|
|
69
67
|
$ convergence -c database.yml -i example.schema --apply
|
70
68
|
|
71
69
|
SET FOREIGN_KEY_CHECKS=0;
|
72
|
-
--> 0.
|
70
|
+
--> 0.0005826340056955814s
|
73
71
|
CREATE TABLE `test_tables` (
|
74
72
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
75
73
|
`name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
|
@@ -78,9 +76,9 @@ CREATE TABLE `test_tables` (
|
|
78
76
|
PRIMARY KEY (`id`),
|
79
77
|
KEY `index_test_tables_on_name` (`name`)
|
80
78
|
) ENGINE=InnoDB ROW_FORMAT=Compact DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci;
|
81
|
-
--> 0.
|
79
|
+
--> 0.017457014000683557s
|
82
80
|
SET FOREIGN_KEY_CHECKS=1;
|
83
|
-
--> 0.
|
81
|
+
--> 0.00019878800230799243s
|
84
82
|
|
85
83
|
$ cat changed_example.schema
|
86
84
|
|
@@ -93,24 +91,29 @@ end
|
|
93
91
|
|
94
92
|
$ convergence -c database.yml -i changed_example.schema --dryrun
|
95
93
|
|
96
|
-
# ALTER TABLE `test_tables` DROP COLUMN `updated_at`;
|
97
|
-
# ALTER TABLE `test_tables` ADD COLUMN `posted_at` datetime NOT NULL AFTER `created_at`;
|
98
94
|
# DROP INDEX `index_test_tables_on_name` ON `test_tables`;
|
95
|
+
# ALTER TABLE `test_tables`
|
96
|
+
# DROP COLUMN `updated_at`;
|
97
|
+
# ALTER TABLE `test_tables`
|
98
|
+
# ADD COLUMN `posted_at` datetime NOT NULL AFTER `created_at`;
|
99
99
|
# ALTER TABLE `test_tables` ENGINE=MyISAM COMMENT='Table Comment Test';
|
100
100
|
|
101
101
|
$ convergence -c database.yml -i changed_example.schema --apply
|
102
|
+
|
102
103
|
SET FOREIGN_KEY_CHECKS=0;
|
103
|
-
--> 0.
|
104
|
-
ALTER TABLE `test_tables` DROP COLUMN `updated_at`;
|
105
|
-
--> 0.034026s
|
106
|
-
ALTER TABLE `test_tables` ADD COLUMN `posted_at` datetime NOT NULL AFTER `created_at`;
|
107
|
-
--> 0.025328s
|
104
|
+
--> 0.0005331430002115667s
|
108
105
|
DROP INDEX `index_test_tables_on_name` ON `test_tables`;
|
109
|
-
--> 0.
|
106
|
+
--> 0.010850776998267975s
|
107
|
+
ALTER TABLE `test_tables`
|
108
|
+
DROP COLUMN `updated_at`;
|
109
|
+
--> 0.025050114003533963s
|
110
|
+
ALTER TABLE `test_tables`
|
111
|
+
ADD COLUMN `posted_at` datetime NOT NULL AFTER `created_at`;
|
112
|
+
--> 0.02903763700305717s
|
110
113
|
ALTER TABLE `test_tables` ENGINE=MyISAM COMMENT='Table Comment Test';
|
111
|
-
--> 0.
|
114
|
+
--> 0.022911186999408528s
|
112
115
|
SET FOREIGN_KEY_CHECKS=1;
|
113
|
-
--> 0.
|
116
|
+
--> 0.003360001996043138s
|
114
117
|
|
115
118
|
$ mysql -u root example_database -e 'show create table test_tables\G'
|
116
119
|
|
@@ -315,4 +318,4 @@ $ bundle exec rspec
|
|
315
318
|
|
316
319
|
## Copyright
|
317
320
|
|
318
|
-
Copyright ©
|
321
|
+
Copyright © 2014-2018 S.nishio. See LICENSE.txt for further details.
|
data/lib/convergence/command.rb
CHANGED
data/lib/convergence/dumper.rb
CHANGED
@@ -6,7 +6,7 @@ class Convergence::Dumper
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def dump_table_dsl(table)
|
9
|
-
table_argument = [
|
9
|
+
table_argument = [table.table_name.to_sym.inspect]
|
10
10
|
table_argument << table.table_options.map { |k, v| key_value_text(k, v) }
|
11
11
|
dsl = "create_table #{table_argument.flatten.join(', ')} do |t|\n"
|
12
12
|
dsl += " #{table.columns.map { |_, column| dump_column(column) }.join("\n ")}"
|
@@ -27,7 +27,7 @@ class Convergence::Dumper
|
|
27
27
|
private
|
28
28
|
|
29
29
|
def dump_column(column)
|
30
|
-
argument = [
|
30
|
+
argument = [column.column_name.to_sym.inspect]
|
31
31
|
case [column.type, column.options[:limit]]
|
32
32
|
when [:tinyint, '1']
|
33
33
|
column_type = "boolean"
|
@@ -63,9 +63,9 @@ class Convergence::Dumper
|
|
63
63
|
def single_or_multiple_symbol(values)
|
64
64
|
values_array = [values].flatten
|
65
65
|
if values_array.size == 1
|
66
|
-
|
66
|
+
values_array.first.to_sym.inspect
|
67
67
|
else
|
68
|
-
|
68
|
+
values.map(&:to_sym).inspect
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -79,6 +79,6 @@ class Convergence::Dumper
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def key_value_symbol(k, v)
|
82
|
-
"#{k}:
|
82
|
+
"#{k}: #{v.to_sym.inspect}"
|
83
83
|
end
|
84
84
|
end
|
@@ -15,9 +15,9 @@ class SQLGenerator::MysqlGenerator < SQLGenerator
|
|
15
15
|
@original_table = original_table
|
16
16
|
sqls = []
|
17
17
|
sqls << change_table_sql(to_table, delta)
|
18
|
-
sqls << ['']
|
19
18
|
sqls << drop_table_sqls(delta)
|
20
19
|
sqls << create_table_sqls(delta)
|
20
|
+
sqls.reject!(&:empty?)
|
21
21
|
sqls.join("\n")
|
22
22
|
end
|
23
23
|
|
@@ -53,6 +53,7 @@ class SQLGenerator::MysqlGenerator < SQLGenerator
|
|
53
53
|
results << alter_change_table_sql(table_name, table_delta[:change_table_option])
|
54
54
|
end
|
55
55
|
end
|
56
|
+
results << '' unless results.empty?
|
56
57
|
results
|
57
58
|
end
|
58
59
|
|
data/lib/convergence/version.rb
CHANGED
@@ -36,5 +36,35 @@ end
|
|
36
36
|
dsl = Convergence::Dumper.new.dump_table_dsl(table1)
|
37
37
|
expect(dsl).to eq(table1_dsl)
|
38
38
|
end
|
39
|
+
|
40
|
+
context "when MySQL identifiers that require quotes in Ruby symbol syntax" do
|
41
|
+
let(:table1) do
|
42
|
+
Convergence::Table.new('dummy-table', engine: 'MyISAM').tap do |t|
|
43
|
+
t.int :id, limit: 11
|
44
|
+
t.varchar :"column-1", limit: 100, null: true, comment: 'column 1'
|
45
|
+
|
46
|
+
t.index :"column-1", name: 'idx_column-1'
|
47
|
+
t.foreign_key :"column-1", reference: 'dummy-ref', reference_column: :"dummy-column"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
let(:table1_dsl) do
|
52
|
+
dsl = <<-DSL
|
53
|
+
create_table :"dummy-table", engine: "MyISAM" do |t|
|
54
|
+
t.int :id, limit: 11
|
55
|
+
t.varchar :"column-1", limit: 100, null: true, comment: "column 1"
|
56
|
+
|
57
|
+
t.index :"column-1", name: "idx_column-1"
|
58
|
+
t.foreign_key :"column-1", reference: :"dummy-ref", reference_column: :"dummy-column", name: "dummy-table_column-1_fk"
|
59
|
+
end
|
60
|
+
DSL
|
61
|
+
dsl.strip
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should be able to dump dsl' do
|
65
|
+
dsl = Convergence::Dumper.new.dump_table_dsl(table1)
|
66
|
+
expect(dsl).to eq(table1_dsl)
|
67
|
+
end
|
68
|
+
end
|
39
69
|
end
|
40
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: convergence
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shinsuke Nishio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mysql2
|