groonga-schema 1.0.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4263ea2b622faf07dde90bbf256235c636287fc9
4
+ data.tar.gz: 103bdca013e9f45a0aaeeb440054eed76df0b900
5
+ SHA512:
6
+ metadata.gz: 53d4be054208120b9f7e8afbac2c5e605bb2929878718cfc6a5f7b6681d794236238d9365a508a1b8ecb9af0fe7cfc5cf2de315bed75748ec505bb5326185933
7
+ data.tar.gz: 6e70cdcdab3aee8125cbde03d2e95f0487fcca9464bfabd5aae356240d4f837d99d43b96e5710e284b869a5d420f320ed890c5a2fcaaad229dc505f8608469a6
data/.yardopts ADDED
@@ -0,0 +1,9 @@
1
+ --protected
2
+ --no-private
3
+ --output doc/reference/en
4
+ --title "groonga-schema API Reference"
5
+ --markup markdown
6
+ --markup-provider kramdown
7
+ --po-dir doc/po
8
+ -
9
+ doc/text/*
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ # -*- ruby -*-
2
+ #
3
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ source "https://rubygems.org/"
20
+
21
+ gemspec
data/README.md ADDED
@@ -0,0 +1,164 @@
1
+ # README
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/groonga-schema.svg)](http://badge.fury.io/rb/groonga-schema)
4
+ [![Build Status](https://travis-ci.org/groonga/groonga-schema.svg?branch=master)](https://travis-ci.org/groonga/groonga-schema)
5
+
6
+ ## Name
7
+
8
+ groonga-schema
9
+
10
+ ## Description
11
+
12
+ Groonga-schema is a Ruby library and tool to processes [Groonga](http://groonga.org/)'s schema.
13
+
14
+ ## Install
15
+
16
+ % gem install groonga-schema
17
+
18
+ ## Usage
19
+
20
+ ### As a tool
21
+
22
+ Here are command lines provided by groonga-schema:
23
+
24
+ * `groonga-schema-diff`: It reports difference between 2 schema.
25
+
26
+ #### `groonga-schema-diff`
27
+
28
+ `groonga-schema-diff` reports difference between 2 schema:
29
+
30
+ ```text
31
+ % groonga-schema-diff FROM_SCHEMA TO_SCHEMA
32
+ ```
33
+
34
+ The output of `groonga-schema-diff` is a Groonga command list. It
35
+ means that you can apply difference by processing the output of
36
+ `groonga-schema-diff` by Groonga. The relation of them are similar to
37
+ `diff` and `patch`.
38
+
39
+ The following example shows about it.
40
+
41
+ Here are sample schema:
42
+
43
+ `current.grn`:
44
+
45
+ ```text
46
+ table_create Logs TABLE_NO_KEY
47
+ column_create Logs timestamp COLUMN_SCALAR ShortText
48
+ ```
49
+
50
+ `new.grn`:
51
+
52
+ ```text
53
+ table_create Logs TABLE_NO_KEY
54
+ column_create Logs timestamp COLUMN_SCALAR Time
55
+ ```
56
+
57
+ In the `current.grn` schema, `Logs.timestamp` column's value type is
58
+ `ShortText`. In the `new.grn` schema, it's `Time`.
59
+
60
+ Here is the output of `groonga-schema-diff`:
61
+
62
+ ```text
63
+ % groonga-schema-diff current.grn new.grn
64
+ column_create --flags "COLUMN_SCALAR" --name "timestamp_new" --table "Logs" --type "Time"
65
+ column_copy --from_name "timestamp" --from_table "Logs" --to_name "timestamp_new" --to_table "Logs"
66
+ column_rename --name "timestamp" --new_name "timestamp_old" --table "Logs"
67
+ column_rename --name "timestamp_new" --new_name "timestamp" --table "Logs"
68
+
69
+ column_remove --name "timestamp_old" --table "Logs"
70
+ ```
71
+
72
+ The output Groonga command list does the followings:
73
+
74
+ 1. Create a new column `Logs.timestamp_new`. The value type of the new column is `Time` not `ShortText`.
75
+
76
+ 2. Copy data to `Logs.timestamp_new` from `Logs.timestamp`.
77
+
78
+ 3. Rename `Logs.timestamp` to `Logs.timestamp_old`.
79
+
80
+ 4. Rename `Logs.timestamp_new` to `Logs.timestamp`.
81
+
82
+ 5. Remove `Logs.timestamp_old`.
83
+
84
+ It means that the output Groonga command list supports data migration.
85
+
86
+ Here is a sample database to show data migration:
87
+
88
+ ```text
89
+ % groonga DB_PATH dump
90
+ table_create Logs TABLE_NO_KEY
91
+ column_create Logs timestamp COLUMN_SCALAR ShortText
92
+
93
+ load --table Logs
94
+ [
95
+ ["_id","timestamp"],
96
+ [1,"2016-08-16 00:00:01"],
97
+ [2,"2016-08-16 00:00:02"],
98
+ [3,"2016-08-16 00:00:03"],
99
+ [4,"2016-08-16 00:00:04"],
100
+ [5,"2016-08-16 00:00:05"]
101
+ ]
102
+ ```
103
+
104
+ You can apply the change by the following command lines:
105
+
106
+ ```text
107
+ % groonga-schema-diff current.grn new.grn > diff.grn
108
+ % groonga --file diff.grn DB_PATH
109
+ ```
110
+
111
+ Or:
112
+
113
+ ```text
114
+ % groonga-schema-diff current.grn new.grn | groonga DB_PATH
115
+ ```
116
+
117
+ Here is the sample database after applying the changes:
118
+
119
+ ```text
120
+ % groonga DB_PATH dump
121
+ table_create Logs TABLE_NO_KEY
122
+ column_create Logs timestamp COLUMN_SCALAR Time
123
+
124
+ load --table Logs
125
+ [
126
+ ["_id","timestamp"],
127
+ [1,1471273201.0],
128
+ [2,1471273202.0],
129
+ [3,1471273203.0],
130
+ [4,1471273204.0],
131
+ [5,1471273205.0]
132
+ ]
133
+ ```
134
+
135
+ `Logs.timestamp` column's value type is changed to `Time` from
136
+ `ShortText` and data are also converted.
137
+
138
+ ### As a library
139
+
140
+ TODO...
141
+
142
+ ## Dependencies
143
+
144
+ * Ruby
145
+
146
+ ## Mailing list
147
+
148
+ * English: [groonga-talk@lists.sourceforge.net](https://lists.sourceforge.net/lists/listinfo/groonga-talk)
149
+ * Japanese: [groonga-dev@lists.sourceforge.jp](http://lists.sourceforge.jp/mailman/listinfo/groonga-dev)
150
+
151
+ ## Chat
152
+
153
+ * English: [Gitter:groonga/en](https://gitter.im/groonga/en)
154
+ * Japanese: [Gitter:groonga/ja](https://gitter.im/groonga/ja)
155
+
156
+ ## Authors
157
+
158
+ * Kouhei Sutou \<kou@clear-code.com\>
159
+
160
+ ## License
161
+
162
+ LGPLv2.1 or later. See doc/text/lgpl-2.1.txt for details.
163
+
164
+ (Kouhei Sutou has a right to change the license including contributed patches.)
data/Rakefile ADDED
@@ -0,0 +1,45 @@
1
+ # -*- ruby -*-
2
+ #
3
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ task :default => :test
20
+
21
+ require "rubygems"
22
+ require "bundler/gem_helper"
23
+ require "packnga"
24
+
25
+ base_dir = File.join(File.dirname(__FILE__))
26
+
27
+ helper = Bundler::GemHelper.new(base_dir)
28
+ def helper.version_tag
29
+ version
30
+ end
31
+
32
+ helper.install
33
+ spec = helper.gemspec
34
+
35
+ Packnga::DocumentTask.new(spec) do |task|
36
+ task.translate_languages = ["ja"]
37
+ end
38
+
39
+ Packnga::ReleaseTask.new(spec) do
40
+ end
41
+
42
+ desc "Run tests"
43
+ task :test do
44
+ ruby("test/run-test.rb")
45
+ end
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (C) 2016 Kouhei Sutou <kou@clear-code.com>
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ require "groonga-schema"
20
+
21
+ exit(GroongaSchema::CommandLine::GroongaSchemaDiff.run(ARGV))