flydata 0.6.3 → 0.6.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/bin/fdredshift +78 -0
- data/circle.yml +1 -1
- data/ext/flydata/{parser/mysql → source_mysql/parser}/.gitignore +0 -0
- data/ext/flydata/{parser/mysql → source_mysql/parser}/dump_parser_ext.cpp +3 -3
- data/ext/flydata/source_mysql/parser/extconf.rb +3 -0
- data/ext/flydata/{parser/mysql → source_mysql/parser}/parser.txt +0 -0
- data/ext/flydata/{parser/mysql → source_mysql/parser}/sql_parser.cpp +0 -0
- data/ext/flydata/{parser/mysql → source_mysql/parser}/sql_parser.h +0 -0
- data/flydata-core/lib/flydata-core/mysql/binlog_pos.rb +34 -32
- data/flydata-core/lib/flydata-core/mysql/compatibility_checker.rb +20 -0
- data/flydata-core/lib/flydata-core/table_def/mysql_table_def.rb +12 -4
- data/flydata-core/lib/flydata-core/table_def/redshift_table_def.rb +60 -6
- data/flydata-core/spec/mysql/binlog_pos_spec.rb +474 -0
- data/flydata-core/spec/table_def/mysql_table_def_spec.rb +57 -0
- data/flydata-core/spec/table_def/mysql_to_redshift_table_def_spec.rb +174 -20
- data/flydata-core/spec/table_def/mysqldump_test_col_comment_with_AUTO_INCREMENT_keyword.dump +43 -0
- data/flydata-core/spec/table_def/mysqldump_test_col_comment_with_not_null_keyword.dump +43 -0
- data/flydata-core/spec/table_def/mysqldump_test_col_comment_with_unique_keyword.dump +43 -0
- data/flydata-core/spec/table_def/mysqldump_test_col_comment_with_unsigned_keyword.dump +43 -0
- data/flydata-core/spec/table_def/redshift_table_def_spec.rb +41 -8
- data/flydata.gemspec +0 -0
- data/lib/flydata/cli.rb +11 -5
- data/lib/flydata/command/base.rb +14 -1
- data/lib/flydata/command/exclusive_runnable.rb +42 -12
- data/lib/flydata/command/helper.rb +6 -6
- data/lib/flydata/command/sender.rb +4 -3
- data/lib/flydata/command/setup.rb +30 -381
- data/lib/flydata/command/stop.rb +1 -0
- data/lib/flydata/command/sync.rb +273 -301
- data/lib/flydata/compatibility_check.rb +24 -117
- data/lib/flydata/fluent-plugins/in_mysql_binlog_flydata.rb +3 -3
- data/lib/flydata/fluent-plugins/mysql/alter_table_query_handler.rb +2 -2
- data/lib/flydata/fluent-plugins/mysql/binlog_record_handler.rb +6 -6
- data/lib/flydata/fluent-plugins/mysql/truncate_table_query_handler.rb +0 -1
- data/lib/flydata/parser.rb +14 -0
- data/lib/flydata/{parser_provider.rb → parser/parser_provider.rb} +6 -4
- data/lib/flydata/parser/source_table.rb +33 -0
- data/lib/flydata/source.rb +105 -0
- data/lib/flydata/source/component.rb +21 -0
- data/lib/flydata/source/errors.rb +7 -0
- data/lib/flydata/source/generate_source_dump.rb +72 -0
- data/lib/flydata/source/parse_dump_and_send.rb +52 -0
- data/lib/flydata/source/setup.rb +31 -0
- data/lib/flydata/source/source_pos.rb +45 -0
- data/lib/flydata/source/sync.rb +56 -0
- data/lib/flydata/source/sync_generate_table_ddl.rb +43 -0
- data/lib/flydata/source_file/setup.rb +17 -0
- data/lib/flydata/source_file/sync.rb +14 -0
- data/lib/flydata/{command → source_mysql/command}/mysql.rb +2 -1
- data/lib/flydata/{command → source_mysql/command}/mysql_command_base.rb +2 -4
- data/lib/flydata/{command → source_mysql/command}/mysqlbinlog.rb +2 -1
- data/lib/flydata/{command → source_mysql/command}/mysqldump.rb +2 -1
- data/lib/flydata/source_mysql/generate_source_dump.rb +53 -0
- data/lib/flydata/source_mysql/mysql_compatibility_check.rb +114 -0
- data/lib/flydata/source_mysql/parse_dump_and_send.rb +28 -0
- data/lib/flydata/{parser/mysql → source_mysql/parser}/.gitignore +0 -0
- data/lib/flydata/{parser/mysql → source_mysql/parser}/dump_parser.rb +32 -67
- data/lib/flydata/{parser/mysql → source_mysql/parser}/mysql_alter_table.treetop +0 -0
- data/lib/flydata/source_mysql/setup.rb +24 -0
- data/lib/flydata/source_mysql/source_pos.rb +21 -0
- data/lib/flydata/source_mysql/sync.rb +45 -0
- data/lib/flydata/source_mysql/sync_generate_table_ddl.rb +40 -0
- data/lib/flydata/{mysql → source_mysql}/table_ddl.rb +6 -17
- data/lib/flydata/source_zendesk/sync_generate_table_ddl.rb +30 -0
- data/lib/flydata/source_zendesk/zendesk_flydata_tabledefs.rb +133 -0
- data/lib/flydata/sync_file_manager.rb +132 -73
- data/lib/flydata/table_ddl.rb +18 -0
- data/spec/flydata/cli_spec.rb +1 -0
- data/spec/flydata/command/exclusive_runnable_spec.rb +19 -8
- data/spec/flydata/command/sender_spec.rb +1 -1
- data/spec/flydata/command/setup_spec.rb +4 -4
- data/spec/flydata/command/sync_spec.rb +97 -134
- data/spec/flydata/compatibility_check_spec.rb +16 -289
- data/spec/flydata/fluent-plugins/mysql/alter_table_query_handler_spec.rb +3 -3
- data/spec/flydata/fluent-plugins/mysql/dml_record_handler_spec.rb +1 -1
- data/spec/flydata/fluent-plugins/mysql/shared_query_handler_context.rb +4 -2
- data/spec/flydata/fluent-plugins/mysql/truncate_query_handler_spec.rb +1 -1
- data/spec/flydata/source_mysql/generate_source_dump_spec.rb +69 -0
- data/spec/flydata/source_mysql/mysql_compatibility_check_spec.rb +280 -0
- data/spec/flydata/{parser/mysql → source_mysql/parser}/alter_table_parser_spec.rb +2 -2
- data/spec/flydata/{parser/mysql → source_mysql/parser}/dump_parser_spec.rb +75 -70
- data/spec/flydata/source_mysql/sync_generate_table_ddl_spec.rb +137 -0
- data/spec/flydata/{mysql → source_mysql}/table_ddl_spec.rb +2 -2
- data/spec/flydata/source_spec.rb +140 -0
- data/spec/flydata/source_zendesk/sync_generate_table_ddl_spec.rb +33 -0
- data/spec/flydata/sync_file_manager_spec.rb +157 -77
- data/tmpl/redshift_mysql_data_entry.conf.tmpl +1 -1
- metadata +56 -23
- data/ext/flydata/parser/mysql/extconf.rb +0 -3
- data/lib/flydata/mysql/binlog_position.rb +0 -22
- data/spec/flydata/mysql/binlog_position_spec.rb +0 -35
@@ -253,6 +253,63 @@ describe MysqlTableDef do
|
|
253
253
|
expect(subject[:columns][4][:type]).to eq("varchar(300)")
|
254
254
|
end
|
255
255
|
end
|
256
|
+
|
257
|
+
context 'when column comment has unique keyword' do
|
258
|
+
let(:dump_file_io) { file_io('mysqldump_test_col_comment_with_unique_keyword.dump')}
|
259
|
+
it 'should not include unique in column def' do
|
260
|
+
expect(subject[:columns]).to eq(
|
261
|
+
[
|
262
|
+
{:column=>"id", :type=>"int4(11)", :auto_increment=>true, :not_null=>true, :primary_key=>true },
|
263
|
+
{:column=>"title", :type=>"varchar(768)", :default=>nil , :comment=>"This column is not unique column."},
|
264
|
+
{:column=>"name", :type=>"text"},
|
265
|
+
{:column=>"num", :type=>"int4(11)", :default=>nil}
|
266
|
+
]
|
267
|
+
)
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
context 'when column comment has unique keyword' do
|
272
|
+
let(:dump_file_io) { file_io('mysqldump_test_col_comment_with_AUTO_INCREMENT_keyword.dump')}
|
273
|
+
it 'should not include AUTO_INCREMENT in column def' do
|
274
|
+
expect(subject[:columns]).to eq(
|
275
|
+
[
|
276
|
+
{:column=>"id", :type=>"int4(11)", :auto_increment=>true, :not_null=>true, :primary_key=>true },
|
277
|
+
{:column=>"title", :type=>"varchar(768)", :default=>nil , :comment=>"This column is not AUTO_INCREMENT column."},
|
278
|
+
{:column=>"name", :type=>"text"},
|
279
|
+
{:column=>"num", :type=>"int4(11)", :default=>nil}
|
280
|
+
]
|
281
|
+
)
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
context 'when column comment has unique keyword' do
|
286
|
+
let(:dump_file_io) { file_io('mysqldump_test_col_comment_with_unsigned_keyword.dump')}
|
287
|
+
it 'should not include unsigned in column def' do
|
288
|
+
expect(subject[:columns]).to eq(
|
289
|
+
[
|
290
|
+
{:column=>"id", :type=>"int4(11)", :auto_increment=>true, :not_null=>true, :primary_key=>true },
|
291
|
+
{:column=>"title", :type=>"varchar(768)", :default=>nil , :comment=>"This column is not unsigned column."},
|
292
|
+
{:column=>"name", :type=>"text"},
|
293
|
+
{:column=>"num", :type=>"int4(11)", :default=>nil}
|
294
|
+
]
|
295
|
+
)
|
296
|
+
end
|
297
|
+
end
|
298
|
+
|
299
|
+
|
300
|
+
context 'when column comment has not null keyword' do
|
301
|
+
let(:dump_file_io) { file_io('mysqldump_test_col_comment_with_not_null_keyword.dump')}
|
302
|
+
it 'should not include not null in column def' do
|
303
|
+
expect(subject[:columns]).to eq(
|
304
|
+
[
|
305
|
+
{:column=>"id", :type=>"int4(11)", :auto_increment=>true, :not_null=>true, :primary_key=>true },
|
306
|
+
{:column=>"title", :type=>"varchar(768)", :default=>nil , :comment=>"This column is not null column."},
|
307
|
+
{:column=>"name", :type=>"text"},
|
308
|
+
{:column=>"num", :type=>"int4(11)", :default=>nil}
|
309
|
+
]
|
310
|
+
)
|
311
|
+
end
|
312
|
+
end
|
256
313
|
end
|
257
314
|
|
258
315
|
describe '.convert_to_flydata_type' do
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'flydata-core/table_def'
|
3
|
+
require 'timecop'
|
3
4
|
|
4
5
|
module FlydataCore
|
5
6
|
module TableDef
|
@@ -22,11 +23,15 @@ module FlydataCore
|
|
22
23
|
MysqlTableDef.create(dump_file_io).to_flydata_tabledef)
|
23
24
|
}
|
24
25
|
|
26
|
+
before do
|
27
|
+
Timecop.freeze(Time.local(2016, 1, 25, 23, 28, 57))
|
28
|
+
end
|
29
|
+
|
25
30
|
context 'with mysqldump_test_table_all' do
|
26
31
|
let(:dump_file_name) { 'mysqldump_test_table_all.dump' }
|
27
32
|
|
28
33
|
it 'should return ddl' do
|
29
|
-
expect(subject).to eq( <<EOT
|
34
|
+
expect(subject).to eq( <<EOT )
|
30
35
|
CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
31
36
|
id integer NOT NULL IDENTITY(1,1),
|
32
37
|
table_name varchar(128) NOT NULL,
|
@@ -44,7 +49,42 @@ CREATE TABLE IF NOT EXISTS "flydata_ctl_tables"(
|
|
44
49
|
created_at timestamp DEFAULT SYSDATE,
|
45
50
|
PRIMARY KEY(id)
|
46
51
|
) DISTKEY(table_name) SORTKEY(table_name);
|
47
|
-
|
52
|
+
BEGIN;
|
53
|
+
DROP TABLE IF EXISTS "test_table_all_flydata20160125232857";
|
54
|
+
CREATE TABLE IF NOT EXISTS "test_table_all" (
|
55
|
+
"id" int8,
|
56
|
+
"col_binary" varchar(202) DEFAULT NULL,
|
57
|
+
"col_blob" varchar(65535),
|
58
|
+
"col_bool" int2 DEFAULT '0',
|
59
|
+
"col_char" varchar(18) DEFAULT NULL,
|
60
|
+
"col_date" date DEFAULT NULL,
|
61
|
+
"col_datetime" timestamp DEFAULT NULL,
|
62
|
+
"col_decimal" numeric(5,2) DEFAULT NULL,
|
63
|
+
"col_double" float8 DEFAULT NULL,
|
64
|
+
"col_float" float4 DEFAULT NULL,
|
65
|
+
"col_float_4_2" float4 DEFAULT NULL,
|
66
|
+
"col_int" int4 DEFAULT NULL,
|
67
|
+
"col_int_6" int4 DEFAULT NULL,
|
68
|
+
"col_longblob" varchar(65535),
|
69
|
+
"col_longtext" varchar(max),
|
70
|
+
"col_mediumblob" varchar(65535),
|
71
|
+
"col_mediumint" int4 DEFAULT NULL,
|
72
|
+
"col_mediumtext" varchar(max),
|
73
|
+
"col_smallint" int2 DEFAULT NULL,
|
74
|
+
"col_text" varchar(max),
|
75
|
+
"col_time" timestamp DEFAULT NULL,
|
76
|
+
"col_timestamp" timestamp DEFAULT SYSDATE,
|
77
|
+
"col_tinyblob" varchar(255),
|
78
|
+
"col_tinyint" int2 DEFAULT NULL,
|
79
|
+
"col_tinytext" varchar(max),
|
80
|
+
"col_varbinary" varchar(512) DEFAULT NULL,
|
81
|
+
"col_varchar" varchar(372) DEFAULT NULL,
|
82
|
+
"col_year" date DEFAULT NULL,
|
83
|
+
"col_year_4" date DEFAULT NULL,
|
84
|
+
"col_year_2" date DEFAULT NULL,
|
85
|
+
PRIMARY KEY ("id")
|
86
|
+
) DISTKEY("id") SORTKEY("id");
|
87
|
+
ALTER TABLE "test_table_all" RENAME TO "test_table_all_flydata20160125232857";
|
48
88
|
CREATE TABLE "test_table_all" (
|
49
89
|
"id" int8,
|
50
90
|
"col_binary" varchar(202) DEFAULT NULL,
|
@@ -147,6 +187,8 @@ INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
|
|
147
187
|
`col_year_2` year(2) DEFAULT NULL,
|
148
188
|
PRIMARY KEY (`id`)
|
149
189
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=\\'test table includes all kind of format type\\';".split("\n").join}');
|
190
|
+
COMMIT;
|
191
|
+
DROP TABLE IF EXISTS "test_table_all_flydata20160125232857";
|
150
192
|
EOT
|
151
193
|
end
|
152
194
|
end
|
@@ -155,7 +197,7 @@ EOT
|
|
155
197
|
let(:dump_file_name) { 'mysqldump_test_bit_table.dump' }
|
156
198
|
|
157
199
|
it 'should return ddl' do
|
158
|
-
expect(subject).to eq( <<EOT
|
200
|
+
expect(subject).to eq( <<EOT )
|
159
201
|
CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
160
202
|
id integer NOT NULL IDENTITY(1,1),
|
161
203
|
table_name varchar(128) NOT NULL,
|
@@ -173,7 +215,15 @@ CREATE TABLE IF NOT EXISTS "flydata_ctl_tables"(
|
|
173
215
|
created_at timestamp DEFAULT SYSDATE,
|
174
216
|
PRIMARY KEY(id)
|
175
217
|
) DISTKEY(table_name) SORTKEY(table_name);
|
176
|
-
|
218
|
+
BEGIN;
|
219
|
+
DROP TABLE IF EXISTS "bit_test_def_1_flydata20160125232857";
|
220
|
+
CREATE TABLE IF NOT EXISTS "bit_test_def_1" (
|
221
|
+
"id" int4,
|
222
|
+
"bit_value" bigint DEFAULT 1,
|
223
|
+
"int_value" int4 DEFAULT 16,
|
224
|
+
PRIMARY KEY ("id")
|
225
|
+
) DISTKEY("id") SORTKEY("id");
|
226
|
+
ALTER TABLE "bit_test_def_1" RENAME TO "bit_test_def_1_flydata20160125232857";
|
177
227
|
CREATE TABLE "bit_test_def_1" (
|
178
228
|
"id" int4,
|
179
229
|
"bit_value" bigint DEFAULT 1,
|
@@ -195,6 +245,8 @@ INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
|
|
195
245
|
`int_value` int(11) DEFAULT x\\'10\\',
|
196
246
|
PRIMARY KEY (`id`)
|
197
247
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;".split("\n").join}');
|
248
|
+
COMMIT;
|
249
|
+
DROP TABLE IF EXISTS "bit_test_def_1_flydata20160125232857";
|
198
250
|
EOT
|
199
251
|
end
|
200
252
|
end
|
@@ -203,7 +255,7 @@ EOT
|
|
203
255
|
let(:dump_file_name) { 'mysqldump_test_foreign_key.dump' }
|
204
256
|
|
205
257
|
it 'should return ddl' do
|
206
|
-
expect(subject).to eq( <<EOT
|
258
|
+
expect(subject).to eq( <<EOT )
|
207
259
|
CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
208
260
|
id integer NOT NULL IDENTITY(1,1),
|
209
261
|
table_name varchar(128) NOT NULL,
|
@@ -221,7 +273,16 @@ CREATE TABLE IF NOT EXISTS "flydata_ctl_tables"(
|
|
221
273
|
created_at timestamp DEFAULT SYSDATE,
|
222
274
|
PRIMARY KEY(id)
|
223
275
|
) DISTKEY(table_name) SORTKEY(table_name);
|
224
|
-
|
276
|
+
BEGIN;
|
277
|
+
DROP TABLE IF EXISTS "product_order_flydata20160125232857";
|
278
|
+
CREATE TABLE IF NOT EXISTS "product_order" (
|
279
|
+
"no" int4,
|
280
|
+
"product_category" int4,
|
281
|
+
"product_id" int4,
|
282
|
+
"customer_id" int4,
|
283
|
+
PRIMARY KEY ("no")
|
284
|
+
) DISTKEY("no") SORTKEY("no");
|
285
|
+
ALTER TABLE "product_order" RENAME TO "product_order_flydata20160125232857";
|
225
286
|
CREATE TABLE "product_order" (
|
226
287
|
"no" int4,
|
227
288
|
"product_category" int4,
|
@@ -250,6 +311,8 @@ INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
|
|
250
311
|
CONSTRAINT `product_order_ibfk_1` FOREIGN KEY (`product_category`, `product_id`) REFERENCES `product` (`category`, `id`) ON UPDATE CASCADE,
|
251
312
|
CONSTRAINT `product_order_ibfk_2` FOREIGN KEY (`customer_id`) REFERENCES `customer` (`id`)
|
252
313
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;".split("\n").join}');
|
314
|
+
COMMIT;
|
315
|
+
DROP TABLE IF EXISTS "product_order_flydata20160125232857";
|
253
316
|
EOT
|
254
317
|
end
|
255
318
|
end
|
@@ -258,7 +321,7 @@ EOT
|
|
258
321
|
let(:dump_file_name) { 'mysqldump_test_table_column_comment.dump' }
|
259
322
|
|
260
323
|
it 'should return ddl' do
|
261
|
-
expect(subject).to eq( <<EOT
|
324
|
+
expect(subject).to eq( <<EOT )
|
262
325
|
CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
263
326
|
id integer NOT NULL IDENTITY(1,1),
|
264
327
|
table_name varchar(128) NOT NULL,
|
@@ -276,7 +339,14 @@ CREATE TABLE IF NOT EXISTS "flydata_ctl_tables"(
|
|
276
339
|
created_at timestamp DEFAULT SYSDATE,
|
277
340
|
PRIMARY KEY(id)
|
278
341
|
) DISTKEY(table_name) SORTKEY(table_name);
|
279
|
-
|
342
|
+
BEGIN;
|
343
|
+
DROP TABLE IF EXISTS "test_table_column_comment_flydata20160125232857";
|
344
|
+
CREATE TABLE IF NOT EXISTS "test_table_column_comment" (
|
345
|
+
"id" int4 DEFAULT '0',
|
346
|
+
"value" varchar(max),
|
347
|
+
PRIMARY KEY ("id")
|
348
|
+
) DISTKEY("id") SORTKEY("id");
|
349
|
+
ALTER TABLE "test_table_column_comment" RENAME TO "test_table_column_comment_flydata20160125232857";
|
280
350
|
CREATE TABLE "test_table_column_comment" (
|
281
351
|
"id" int4 DEFAULT '0',
|
282
352
|
"value" varchar(max),
|
@@ -297,6 +367,8 @@ INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
|
|
297
367
|
`value` text,
|
298
368
|
PRIMARY KEY (`id`)
|
299
369
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=\\'column comment test\\';".split("\n").join}');
|
370
|
+
COMMIT;
|
371
|
+
DROP TABLE IF EXISTS "test_table_column_comment_flydata20160125232857";
|
300
372
|
EOT
|
301
373
|
end
|
302
374
|
end
|
@@ -305,7 +377,7 @@ EOT
|
|
305
377
|
let(:dump_file_name) { 'mysqldump_test_table_enum.dump' }
|
306
378
|
|
307
379
|
it 'should return ddl' do
|
308
|
-
expect(subject).to eq( <<EOT
|
380
|
+
expect(subject).to eq( <<EOT )
|
309
381
|
CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
310
382
|
id integer NOT NULL IDENTITY(1,1),
|
311
383
|
table_name varchar(128) NOT NULL,
|
@@ -323,7 +395,16 @@ CREATE TABLE IF NOT EXISTS "flydata_ctl_tables"(
|
|
323
395
|
created_at timestamp DEFAULT SYSDATE,
|
324
396
|
PRIMARY KEY(id)
|
325
397
|
) DISTKEY(table_name) SORTKEY(table_name);
|
326
|
-
|
398
|
+
BEGIN;
|
399
|
+
DROP TABLE IF EXISTS "test_table_enum_flydata20160125232857";
|
400
|
+
CREATE TABLE IF NOT EXISTS "test_table_enum" (
|
401
|
+
"id" int4,
|
402
|
+
"enum_1" varchar encode bytedict DEFAULT NULL,
|
403
|
+
"enum_2" varchar encode bytedict DEFAULT 'a',
|
404
|
+
"enum_3" varchar encode bytedict,
|
405
|
+
PRIMARY KEY ("id")
|
406
|
+
) DISTKEY("id") SORTKEY("id");
|
407
|
+
ALTER TABLE "test_table_enum" RENAME TO "test_table_enum_flydata20160125232857";
|
327
408
|
CREATE TABLE "test_table_enum" (
|
328
409
|
"id" int4,
|
329
410
|
"enum_1" varchar encode bytedict DEFAULT NULL,
|
@@ -348,6 +429,8 @@ INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
|
|
348
429
|
`enum_3` enum(\\'e\\',\\'f\\',\\'g\\') NOT NULL,
|
349
430
|
PRIMARY KEY (`id`)
|
350
431
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=\\'with enum column\\';".split("\n").join}');
|
432
|
+
COMMIT;
|
433
|
+
DROP TABLE IF EXISTS "test_table_enum_flydata20160125232857";
|
351
434
|
EOT
|
352
435
|
end
|
353
436
|
end
|
@@ -356,7 +439,7 @@ EOT
|
|
356
439
|
let(:dump_file_name) { 'mysqldump_test_table_multi_pk.dump' }
|
357
440
|
|
358
441
|
it 'should return ddl' do
|
359
|
-
expect(subject).to eq( <<EOT
|
442
|
+
expect(subject).to eq( <<EOT )
|
360
443
|
CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
361
444
|
id integer NOT NULL IDENTITY(1,1),
|
362
445
|
table_name varchar(128) NOT NULL,
|
@@ -374,7 +457,15 @@ CREATE TABLE IF NOT EXISTS "flydata_ctl_tables"(
|
|
374
457
|
created_at timestamp DEFAULT SYSDATE,
|
375
458
|
PRIMARY KEY(id)
|
376
459
|
) DISTKEY(table_name) SORTKEY(table_name);
|
377
|
-
|
460
|
+
BEGIN;
|
461
|
+
DROP TABLE IF EXISTS "test_table_multi_pk_flydata20160125232857";
|
462
|
+
CREATE TABLE IF NOT EXISTS "test_table_multi_pk" (
|
463
|
+
"id1" int4 DEFAULT '0',
|
464
|
+
"id2" int4 DEFAULT '0',
|
465
|
+
"value" varchar(max),
|
466
|
+
PRIMARY KEY ("id1","id2")
|
467
|
+
) DISTKEY("id1") SORTKEY("id1","id2");
|
468
|
+
ALTER TABLE "test_table_multi_pk" RENAME TO "test_table_multi_pk_flydata20160125232857";
|
378
469
|
CREATE TABLE "test_table_multi_pk" (
|
379
470
|
"id1" int4 DEFAULT '0',
|
380
471
|
"id2" int4 DEFAULT '0',
|
@@ -396,6 +487,8 @@ INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
|
|
396
487
|
`value` text,
|
397
488
|
PRIMARY KEY (`id1`,`id2`)
|
398
489
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT=\\'multiple primary key\\';".split("\n").join}');
|
490
|
+
COMMIT;
|
491
|
+
DROP TABLE IF EXISTS "test_table_multi_pk_flydata20160125232857";
|
399
492
|
EOT
|
400
493
|
end
|
401
494
|
end
|
@@ -412,7 +505,7 @@ EOT
|
|
412
505
|
let(:dump_file_name) { 'mysqldump_test_unique_key.dump' }
|
413
506
|
|
414
507
|
it 'should return ddl' do
|
415
|
-
expect(subject).to eq( <<EOT
|
508
|
+
expect(subject).to eq( <<EOT )
|
416
509
|
CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
417
510
|
id integer NOT NULL IDENTITY(1,1),
|
418
511
|
table_name varchar(128) NOT NULL,
|
@@ -430,7 +523,16 @@ CREATE TABLE IF NOT EXISTS "flydata_ctl_tables"(
|
|
430
523
|
created_at timestamp DEFAULT SYSDATE,
|
431
524
|
PRIMARY KEY(id)
|
432
525
|
) DISTKEY(table_name) SORTKEY(table_name);
|
433
|
-
|
526
|
+
BEGIN;
|
527
|
+
DROP TABLE IF EXISTS "sample1_flydata20160125232857";
|
528
|
+
CREATE TABLE IF NOT EXISTS "sample1" (
|
529
|
+
"id" int4,
|
530
|
+
"title" varchar(768) DEFAULT NULL,
|
531
|
+
"name" varchar(max),
|
532
|
+
"num" int4 DEFAULT NULL,
|
533
|
+
PRIMARY KEY ("id")
|
534
|
+
) DISTKEY("id") SORTKEY("id");
|
535
|
+
ALTER TABLE "sample1" RENAME TO "sample1_flydata20160125232857";
|
434
536
|
CREATE TABLE "sample1" (
|
435
537
|
"id" int4,
|
436
538
|
"title" varchar(768) DEFAULT NULL,
|
@@ -457,6 +559,8 @@ INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
|
|
457
559
|
UNIQUE KEY `title` (`title`),
|
458
560
|
UNIQUE KEY `num` (`num`)
|
459
561
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;".split("\n").join}');
|
562
|
+
COMMIT;
|
563
|
+
DROP TABLE IF EXISTS "sample1_flydata20160125232857";
|
460
564
|
EOT
|
461
565
|
end
|
462
566
|
end
|
@@ -465,7 +569,7 @@ EOT
|
|
465
569
|
let(:dump_file_name) { 'mysqldump_test_unique_key2.dump' }
|
466
570
|
|
467
571
|
it 'should return ddl' do
|
468
|
-
expect(subject).to eq( <<EOT
|
572
|
+
expect(subject).to eq( <<EOT )
|
469
573
|
CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
470
574
|
id integer NOT NULL IDENTITY(1,1),
|
471
575
|
table_name varchar(128) NOT NULL,
|
@@ -483,7 +587,16 @@ CREATE TABLE IF NOT EXISTS "flydata_ctl_tables"(
|
|
483
587
|
created_at timestamp DEFAULT SYSDATE,
|
484
588
|
PRIMARY KEY(id)
|
485
589
|
) DISTKEY(table_name) SORTKEY(table_name);
|
486
|
-
|
590
|
+
BEGIN;
|
591
|
+
DROP TABLE IF EXISTS "sample1_flydata20160125232857";
|
592
|
+
CREATE TABLE IF NOT EXISTS "sample1" (
|
593
|
+
"id" int4,
|
594
|
+
"title" varchar(768) DEFAULT NULL,
|
595
|
+
"name" varchar(max),
|
596
|
+
"num" int4 DEFAULT NULL,
|
597
|
+
PRIMARY KEY ("id")
|
598
|
+
) DISTKEY("id") SORTKEY("id");
|
599
|
+
ALTER TABLE "sample1" RENAME TO "sample1_flydata20160125232857";
|
487
600
|
CREATE TABLE "sample1" (
|
488
601
|
"id" int4,
|
489
602
|
"title" varchar(768) DEFAULT NULL,
|
@@ -510,6 +623,8 @@ INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
|
|
510
623
|
UNIQUE KEY `title` (`title`),
|
511
624
|
UNIQUE KEY `index_num` (`num`)
|
512
625
|
) ENGINE=InnoDB DEFAULT CHARSET=latin1;".split("\n").join}');
|
626
|
+
COMMIT;
|
627
|
+
DROP TABLE IF EXISTS "sample1_flydata20160125232857";
|
513
628
|
EOT
|
514
629
|
end
|
515
630
|
end
|
@@ -518,7 +633,7 @@ EOT
|
|
518
633
|
let(:dump_file_name) { 'mysqldump_test_unique_key3.dump' }
|
519
634
|
|
520
635
|
it 'should return ddl' do
|
521
|
-
expect(subject).to eq( <<EOT
|
636
|
+
expect(subject).to eq( <<EOT )
|
522
637
|
CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
523
638
|
id integer NOT NULL IDENTITY(1,1),
|
524
639
|
table_name varchar(128) NOT NULL,
|
@@ -536,7 +651,30 @@ CREATE TABLE IF NOT EXISTS "flydata_ctl_tables"(
|
|
536
651
|
created_at timestamp DEFAULT SYSDATE,
|
537
652
|
PRIMARY KEY(id)
|
538
653
|
) DISTKEY(table_name) SORTKEY(table_name);
|
539
|
-
|
654
|
+
BEGIN;
|
655
|
+
DROP TABLE IF EXISTS "invoice_items_flydata20160125232857";
|
656
|
+
CREATE TABLE IF NOT EXISTS "invoice_items" (
|
657
|
+
"id" int4,
|
658
|
+
"app_id" int4,
|
659
|
+
"subscription_id" int4,
|
660
|
+
"overage_id" varchar(765),
|
661
|
+
"stripe_invoice_item_id" varchar(765) DEFAULT NULL,
|
662
|
+
"stripe_error" varchar(765) DEFAULT NULL,
|
663
|
+
"synced_to_stripe" int2 DEFAULT '0',
|
664
|
+
"description" varchar(max),
|
665
|
+
"item_name" varchar(765),
|
666
|
+
"item_cost" int4,
|
667
|
+
"item_count" int4,
|
668
|
+
"total_cost" int4,
|
669
|
+
"created_at" timestamp DEFAULT NULL,
|
670
|
+
"updated_at" timestamp DEFAULT NULL,
|
671
|
+
"bill_ahead" int2 DEFAULT '0',
|
672
|
+
"bill_ahead_resolved_at" timestamp DEFAULT NULL,
|
673
|
+
"stripe_invoice_id" varchar(765) DEFAULT NULL,
|
674
|
+
"is_vat" int2 DEFAULT '0',
|
675
|
+
PRIMARY KEY ("id")
|
676
|
+
) DISTKEY("id") SORTKEY("id");
|
677
|
+
ALTER TABLE "invoice_items" RENAME TO "invoice_items_flydata20160125232857";
|
540
678
|
CREATE TABLE "invoice_items" (
|
541
679
|
"id" int4,
|
542
680
|
"app_id" int4,
|
@@ -604,6 +742,8 @@ INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
|
|
604
742
|
PRIMARY KEY (`id`),
|
605
743
|
UNIQUE KEY `index_invoice_items_on_app_id_and_overage_id_and_item_name` (`app_id`,`overage_id`(32),`item_name`(32)) USING BTREE
|
606
744
|
) ENGINE=InnoDB AUTO_INCREMENT=16654 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;".split("\n").join}');
|
745
|
+
COMMIT;
|
746
|
+
DROP TABLE IF EXISTS "invoice_items_flydata20160125232857";
|
607
747
|
EOT
|
608
748
|
end
|
609
749
|
end
|
@@ -612,7 +752,7 @@ EOT
|
|
612
752
|
let(:dump_file_name) { 'mysqldump_test_unsigned.dump' }
|
613
753
|
|
614
754
|
it 'should return ddl' do
|
615
|
-
expect(subject).to eq( <<EOT
|
755
|
+
expect(subject).to eq( <<EOT )
|
616
756
|
CREATE TABLE IF NOT EXISTS "flydata_ctl_columns"(
|
617
757
|
id integer NOT NULL IDENTITY(1,1),
|
618
758
|
table_name varchar(128) NOT NULL,
|
@@ -630,7 +770,19 @@ CREATE TABLE IF NOT EXISTS "flydata_ctl_tables"(
|
|
630
770
|
created_at timestamp DEFAULT SYSDATE,
|
631
771
|
PRIMARY KEY(id)
|
632
772
|
) DISTKEY(table_name) SORTKEY(table_name);
|
633
|
-
|
773
|
+
BEGIN;
|
774
|
+
DROP TABLE IF EXISTS "zerofill_table_flydata20160125232857";
|
775
|
+
CREATE TABLE IF NOT EXISTS "zerofill_table" (
|
776
|
+
"id" int4,
|
777
|
+
"value_int" int8 DEFAULT NULL,
|
778
|
+
"value_float" float4 DEFAULT NULL,
|
779
|
+
"value_dec" numeric(10,2) DEFAULT NULL,
|
780
|
+
"value_double" float8 DEFAULT NULL,
|
781
|
+
"name" varchar(768) DEFAULT NULL,
|
782
|
+
"value_small_int" int4 DEFAULT NULL,
|
783
|
+
PRIMARY KEY ("id")
|
784
|
+
) DISTKEY("id") SORTKEY("id");
|
785
|
+
ALTER TABLE "zerofill_table" RENAME TO "zerofill_table_flydata20160125232857";
|
634
786
|
CREATE TABLE "zerofill_table" (
|
635
787
|
"id" int4,
|
636
788
|
"value_int" int8 DEFAULT NULL,
|
@@ -664,6 +816,8 @@ INSERT INTO "flydata_ctl_tables" (table_name, attribute, value) VALUES
|
|
664
816
|
`value_small_int` smallint(5) unsigned DEFAULT NULL,
|
665
817
|
PRIMARY KEY (`id`)
|
666
818
|
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=latin1;".split("\n").join}');
|
819
|
+
COMMIT;
|
820
|
+
DROP TABLE IF EXISTS "zerofill_table_flydata20160125232857";
|
667
821
|
EOT
|
668
822
|
end
|
669
823
|
end
|