mysql2postgres 0.3.3 → 0.4.1
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/.gitignore +2 -0
- data/README.md +9 -4
- data/Rakefile +1 -1
- data/bin/mysql2postgres +6 -14
- data/lib/mysql2postgres/connection.rb +19 -19
- data/lib/mysql2postgres/converter.rb +1 -2
- data/lib/mysql2postgres/mysql_reader.rb +20 -16
- data/lib/mysql2postgres/postgres_db_writer.rb +4 -5
- data/lib/mysql2postgres/postgres_file_writer.rb +20 -6
- data/lib/mysql2postgres/postgres_writer.rb +66 -31
- data/lib/mysql2postgres/version.rb +1 -1
- data/lib/mysql2postgres.rb +58 -25
- data/mysql2postgres.gemspec +7 -11
- data/test/fixtures/config_all_options.yml +14 -11
- data/test/fixtures/config_min_options.yml +16 -0
- data/test/fixtures/config_to_file.yml +31 -0
- data/test/integration/convert_to_db_test.rb +15 -8
- data/test/integration/convert_to_file_test.rb +33 -18
- data/test/integration/converter_test.rb +10 -3
- data/test/integration/{mysql_reader_base_test.rb → mysql_reader_connection_test.rb} +9 -6
- data/test/integration/mysql_reader_test.rb +7 -4
- data/test/integration/postgres_db_writer_test.rb +24 -0
- data/test/test_helper.rb +22 -67
- data/test/units/mysql_test.rb +10 -0
- data/test/units/option_test.rb +5 -8
- data/test/units/postgres_file_writer_test.rb +4 -2
- metadata +14 -82
- data/lib/mysql2postgres/writer.rb +0 -9
- data/test/integration/postgres_db_writer_base_test.rb +0 -18
@@ -1,20 +1,21 @@
|
|
1
1
|
mysql:
|
2
|
-
hostname:
|
2
|
+
hostname: 127.0.0.1
|
3
3
|
port: 3306
|
4
|
-
|
5
|
-
|
6
|
-
password: secretpassword
|
4
|
+
username: root
|
5
|
+
password: BestPasswordEver
|
7
6
|
database: somename
|
7
|
+
encoding: utf8mb4
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
# if MYSQL2POSTGRES_ENV and RAILS_ENV is missing, development is used!
|
10
|
+
destinations:
|
11
|
+
development:
|
12
|
+
adapter: file
|
13
|
+
filename: /tmp/exported_file.sql
|
13
14
|
test:
|
14
15
|
hostname: localhost
|
15
16
|
port: 5432
|
16
|
-
username:
|
17
|
-
password:
|
17
|
+
username: postgres
|
18
|
+
password: postgres
|
18
19
|
database: somename
|
19
20
|
|
20
21
|
# if tables is given, only the listed tables will be converted. leave empty to convert all tables.
|
@@ -29,8 +30,10 @@ exclude_tables:
|
|
29
30
|
- table5
|
30
31
|
- table6
|
31
32
|
|
33
|
+
dump_file_directory: /tmp
|
34
|
+
|
32
35
|
# if suppress_data is true, only the schema definition will be exported/migrated, and not the data
|
33
|
-
suppress_data:
|
36
|
+
suppress_data: false
|
34
37
|
|
35
38
|
# if suppress_ddl is true, only the data will be exported/imported, and not the schema
|
36
39
|
suppress_ddl: false
|
@@ -0,0 +1,16 @@
|
|
1
|
+
mysql:
|
2
|
+
hostname: localhost
|
3
|
+
username: root
|
4
|
+
password: BestPasswordEver
|
5
|
+
database: somename
|
6
|
+
|
7
|
+
# if MYSQL2POSTGRES_ENV and RAILS_ENV is missing, development is used!
|
8
|
+
destinations:
|
9
|
+
test:
|
10
|
+
hostname: localhost
|
11
|
+
port: 5432
|
12
|
+
username: somename
|
13
|
+
password: secretpassword
|
14
|
+
database: somename
|
15
|
+
|
16
|
+
# all options are false as default
|
@@ -0,0 +1,31 @@
|
|
1
|
+
mysql:
|
2
|
+
hostname: 127.0.0.1
|
3
|
+
port: 3306
|
4
|
+
username: root
|
5
|
+
password: BestPasswordEver
|
6
|
+
database: somename
|
7
|
+
encoding: utf8mb4
|
8
|
+
|
9
|
+
# if MYSQL2POSTGRES_ENV and RAILS_ENV is missing, development is used!
|
10
|
+
destinations:
|
11
|
+
test:
|
12
|
+
adapter: file
|
13
|
+
filename: /tmp/exported_file.sql
|
14
|
+
|
15
|
+
# if tables is given, only the listed tables will be converted. leave empty to convert all tables.
|
16
|
+
tables:
|
17
|
+
- table1
|
18
|
+
- table2
|
19
|
+
- table3
|
20
|
+
- table4
|
21
|
+
|
22
|
+
dump_file_directory: /tmp
|
23
|
+
|
24
|
+
# if suppress_data is true, only the schema definition will be exported/migrated, and not the data
|
25
|
+
suppress_data: false
|
26
|
+
|
27
|
+
# if suppress_ddl is true, only the data will be exported/imported, and not the schema
|
28
|
+
suppress_ddl: false
|
29
|
+
|
30
|
+
# if force_truncate is true, forces a table truncate before table loading
|
31
|
+
force_truncate: false
|
@@ -6,18 +6,25 @@ class ConvertToDbTest < Test::Unit::TestCase
|
|
6
6
|
class << self
|
7
7
|
def startup
|
8
8
|
seed_test_database
|
9
|
-
@options = get_test_config_by_label :localmysql_to_db_convert_all
|
10
|
-
@mysql2postgres = Mysql2postgres.new @options
|
11
|
-
@mysql2postgres.convert
|
12
|
-
@mysql2postgres.writer.open
|
13
9
|
end
|
10
|
+
end
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
def setup
|
13
|
+
@mysql2postgres = instance_from_file
|
14
|
+
@options = @mysql2postgres.options
|
15
|
+
@options[:force_truncate] = true
|
16
|
+
@options.delete :tables # convert all available tables
|
17
|
+
|
18
|
+
@mysql2postgres.convert
|
19
|
+
@mysql2postgres.writer.connection.open
|
20
|
+
end
|
21
|
+
|
22
|
+
def teardown
|
23
|
+
@mysql2postgres&.writer&.connection&.finish
|
18
24
|
end
|
19
25
|
|
20
26
|
def test_table_creation
|
21
|
-
|
27
|
+
tables = @mysql2postgres.writer.connection.tables
|
28
|
+
assert tables.include?('numeric_types_basics')
|
22
29
|
end
|
23
30
|
end
|
@@ -3,18 +3,22 @@
|
|
3
3
|
require File.expand_path '../test_helper', __dir__
|
4
4
|
|
5
5
|
class ConvertToFileTest < Test::Unit::TestCase
|
6
|
+
attr_reader :content
|
7
|
+
|
6
8
|
class << self
|
7
9
|
def startup
|
8
|
-
seed_test_database
|
9
|
-
@options = get_test_config_by_label :localmysql_to_file_convert_all
|
10
|
-
@mysql2postgres = Mysql2postgres.new @options
|
11
|
-
@mysql2postgres.convert
|
12
|
-
@content = File.read @mysql2postgres.options[:destfile]
|
10
|
+
seed_test_database option_file: 'config_to_file'
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
|
-
def
|
17
|
-
|
14
|
+
def setup
|
15
|
+
@mysql2postgres = instance_from_file 'config_to_file'
|
16
|
+
@options = @mysql2postgres.options
|
17
|
+
@options[:force_truncate] = true
|
18
|
+
@options.delete :tables # convert all available tables
|
19
|
+
|
20
|
+
@mysql2postgres.convert
|
21
|
+
@content = File.read @mysql2postgres.options[:destination][:filename]
|
18
22
|
end
|
19
23
|
|
20
24
|
def test_table_creation
|
@@ -23,46 +27,57 @@ class ConvertToFileTest < Test::Unit::TestCase
|
|
23
27
|
end
|
24
28
|
|
25
29
|
def test_basic_numerics_tinyint
|
26
|
-
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_tinyint" smallint,.*\)', Regexp::MULTILINE)
|
30
|
+
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_tinyint" smallint,.*\)', Regexp::MULTILINE)
|
31
|
+
.match(content)
|
27
32
|
end
|
28
33
|
|
29
34
|
def test_basic_numerics_smallint
|
30
|
-
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_smallint" integer,.*\)', Regexp::MULTILINE)
|
35
|
+
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_smallint" integer,.*\)', Regexp::MULTILINE)
|
36
|
+
.match(content)
|
31
37
|
end
|
32
38
|
|
33
39
|
def test_basic_numerics_mediumint
|
34
|
-
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_mediumint" integer,.*\)', Regexp::MULTILINE)
|
40
|
+
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_mediumint" integer,.*\)', Regexp::MULTILINE)
|
41
|
+
.match(content)
|
35
42
|
end
|
36
43
|
|
37
44
|
def test_basic_numerics_int
|
38
|
-
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_int" integer,.*\)', Regexp::MULTILINE)
|
45
|
+
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_int" integer,.*\)', Regexp::MULTILINE)
|
46
|
+
.match(content)
|
39
47
|
end
|
40
48
|
|
41
49
|
def test_basic_numerics_integer
|
42
|
-
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_integer" integer,.*\)', Regexp::MULTILINE)
|
50
|
+
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_integer" integer,.*\)', Regexp::MULTILINE)
|
51
|
+
.match(content)
|
43
52
|
end
|
44
53
|
|
45
54
|
def test_basic_numerics_bigint
|
46
|
-
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_bigint" bigint,.*\)', Regexp::MULTILINE)
|
55
|
+
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_bigint" bigint,.*\)', Regexp::MULTILINE)
|
56
|
+
.match(content)
|
47
57
|
end
|
48
58
|
|
49
59
|
def test_basic_numerics_real
|
50
|
-
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_real" double precision,.*\)', Regexp::MULTILINE)
|
60
|
+
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_real" double precision,.*\)', Regexp::MULTILINE)
|
61
|
+
.match(content)
|
51
62
|
end
|
52
63
|
|
53
64
|
def test_basic_numerics_double
|
54
|
-
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_double" double precision,.*\)', Regexp::MULTILINE)
|
65
|
+
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_double" double precision,.*\)', Regexp::MULTILINE)
|
66
|
+
.match(content)
|
55
67
|
end
|
56
68
|
|
57
69
|
def test_basic_numerics_float
|
58
|
-
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_float" double precision,.*\)', Regexp::MULTILINE)
|
70
|
+
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_float" double precision,.*\)', Regexp::MULTILINE)
|
71
|
+
.match(content)
|
59
72
|
end
|
60
73
|
|
61
74
|
def test_basic_numerics_decimal
|
62
|
-
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_decimal" numeric\(10, 0\),.*\)', Regexp::MULTILINE)
|
75
|
+
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_decimal" numeric\(10, 0\),.*\)', Regexp::MULTILINE)
|
76
|
+
.match(content)
|
63
77
|
end
|
64
78
|
|
65
79
|
def test_basic_numerics_numeric
|
66
|
-
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_numeric" numeric\(10, 0\)[\w\n]*\)', Regexp::MULTILINE)
|
80
|
+
assert_not_nil Regexp.new('CREATE TABLE "numeric_types_basics".*"f_numeric" numeric\(10, 0\)[\w\n]*\)', Regexp::MULTILINE)
|
81
|
+
.match(content)
|
67
82
|
end
|
68
83
|
end
|
@@ -5,15 +5,22 @@ require File.expand_path '../test_helper', __dir__
|
|
5
5
|
class ConverterTest < Test::Unit::TestCase
|
6
6
|
class << self
|
7
7
|
def startup
|
8
|
-
seed_test_database
|
9
|
-
@options = get_test_config_by_label :localmysql_to_file_convert_nothing
|
8
|
+
seed_test_database option_file: 'config_to_file'
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
12
|
+
def setup
|
13
|
+
@options = options_from_file 'config_to_file'
|
14
|
+
@options[:suppress_data] = true
|
15
|
+
@options[:suppress_ddl] = true
|
16
|
+
|
17
|
+
@destfile = get_temp_file 'mysql2postgres_test'
|
18
|
+
end
|
19
|
+
|
13
20
|
def test_new_converter
|
14
21
|
assert_nothing_raised do
|
15
22
|
reader = get_test_reader @options
|
16
|
-
writer =
|
23
|
+
writer = Mysql2postgres::PostgresFileWriter.new @destfile, @options[:destination]
|
17
24
|
converter = Mysql2postgres::Converter.new reader, writer, @options
|
18
25
|
assert_equal 0, converter.convert
|
19
26
|
end
|
@@ -2,23 +2,26 @@
|
|
2
2
|
|
3
3
|
require File.expand_path '../test_helper', __dir__
|
4
4
|
|
5
|
-
class
|
5
|
+
class MysqlReaderConnectionTest < Test::Unit::TestCase
|
6
6
|
class << self
|
7
7
|
def startup
|
8
|
-
seed_test_database
|
9
|
-
@options = get_test_config_by_label :localmysql_to_file_convert_nothing
|
8
|
+
seed_test_database option_file: 'config_to_file'
|
10
9
|
end
|
11
10
|
end
|
12
11
|
|
12
|
+
def setup
|
13
|
+
@options = options_from_file 'config_to_file'
|
14
|
+
end
|
15
|
+
|
13
16
|
def test_mysql_connection
|
14
17
|
assert_nothing_raised do
|
15
|
-
|
18
|
+
Mysql2postgres::MysqlReader.new @options
|
16
19
|
end
|
17
20
|
end
|
18
21
|
|
19
22
|
def test_mysql_reconnect
|
20
23
|
assert_nothing_raised do
|
21
|
-
reader =
|
24
|
+
reader = Mysql2postgres::MysqlReader.new @options
|
22
25
|
reader.reconnect
|
23
26
|
end
|
24
27
|
end
|
@@ -27,7 +30,7 @@ class MysqlReaderBaseTest < Test::Unit::TestCase
|
|
27
30
|
assert_nothing_raised do
|
28
31
|
@options[:mysql][:port] = ''
|
29
32
|
@options[:mysql][:socket] = ''
|
30
|
-
|
33
|
+
Mysql2postgres::MysqlReader.new @options
|
31
34
|
end
|
32
35
|
end
|
33
36
|
end
|
@@ -5,12 +5,15 @@ require File.expand_path '../test_helper', __dir__
|
|
5
5
|
class MysqlReaderTest < Test::Unit::TestCase
|
6
6
|
class << self
|
7
7
|
def startup
|
8
|
-
seed_test_database
|
9
|
-
@options = get_test_config_by_label :localmysql_to_file_convert_nothing
|
10
|
-
@reader = get_test_reader @options
|
8
|
+
seed_test_database option_file: 'config_to_file'
|
11
9
|
end
|
12
10
|
end
|
13
11
|
|
12
|
+
def setup
|
13
|
+
@options = options_from_file 'config_to_file'
|
14
|
+
@reader = get_test_reader @options
|
15
|
+
end
|
16
|
+
|
14
17
|
def test_db_connection
|
15
18
|
assert_nothing_raised do
|
16
19
|
@reader.mysql.ping
|
@@ -26,7 +29,7 @@ class MysqlReaderTest < Test::Unit::TestCase
|
|
26
29
|
def test_paginated_read
|
27
30
|
expected_rows = 3
|
28
31
|
page_size = 2
|
29
|
-
expected_pages = (1.0 * expected_rows / page_size).ceil
|
32
|
+
# expected_pages = (1.0 * expected_rows / page_size).ceil
|
30
33
|
|
31
34
|
row_count = my_row_count = 0
|
32
35
|
table = @reader.tables.find { |t| t.name == 'numeric_types_basics' }
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path '../test_helper', __dir__
|
4
|
+
|
5
|
+
class PostgresDbWriterTest < Test::Unit::TestCase
|
6
|
+
class << self
|
7
|
+
def startup
|
8
|
+
seed_test_database
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@options = options_from_file
|
14
|
+
@options[:suppress_data] = true
|
15
|
+
@options[:suppress_ddl] = true
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_pg_connection
|
19
|
+
assert_nothing_raised do
|
20
|
+
Mysql2postgres::PostgresDbWriter.new Tempfile.new('mysql2postgres_test_').path,
|
21
|
+
@options[:destination]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -4,47 +4,37 @@ require 'rubygems'
|
|
4
4
|
require 'test/unit'
|
5
5
|
require 'debug' if ENV.fetch('ENABLE_DEBUG', nil) == '1'
|
6
6
|
|
7
|
-
require File.expand_path('
|
8
|
-
require File.expand_path('../lib/mysql2postgres/converter', __dir__)
|
9
|
-
require File.expand_path('../lib/mysql2postgres/mysql_reader', __dir__)
|
10
|
-
require File.expand_path('../lib/mysql2postgres/writer', __dir__)
|
11
|
-
require File.expand_path('../lib/mysql2postgres/postgres_writer', __dir__)
|
12
|
-
require File.expand_path('../lib/mysql2postgres/postgres_file_writer', __dir__)
|
13
|
-
require File.expand_path('../lib/mysql2postgres/postgres_db_writer', __dir__)
|
7
|
+
require File.expand_path('lib/mysql2postgres')
|
14
8
|
|
15
|
-
def
|
16
|
-
|
17
|
-
|
18
|
-
rc = system "mysql -u#{options[:mysql][:username]} #{options[:mysql][:database]} < #{seedfilepath}"
|
19
|
-
raise StandardError unless rc
|
9
|
+
def load_yaml_file(file = 'config_all_options')
|
10
|
+
YAML.load_file "#{__dir__}/fixtures/#{file}.yml"
|
11
|
+
end
|
20
12
|
|
21
|
-
|
22
|
-
|
23
|
-
raise 'Failed to seed integration test db. See README for setup requirements.'
|
13
|
+
def instance_from_file(file = 'config_all_options')
|
14
|
+
Mysql2postgres.new load_yaml_file(file)
|
24
15
|
end
|
25
16
|
|
26
|
-
def
|
27
|
-
|
28
|
-
mysql2postgres::MysqlReader.new options
|
29
|
-
rescue StandardError
|
30
|
-
raise 'Failed to initialize integration test db. See README for setup requirements.'
|
17
|
+
def options_from_file(file = 'config_all_options')
|
18
|
+
instance_from_file(file).options
|
31
19
|
end
|
32
20
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
21
|
+
def seed_test_database(option_file: 'config_all_options', sql_file: 'seed_integration_tests.sql')
|
22
|
+
options = options_from_file option_file
|
23
|
+
seedfilepath = File.expand_path "test/fixtures/#{sql_file}"
|
24
|
+
system 'mysql ' \
|
25
|
+
"--host #{options[:mysql][:hostname]} " \
|
26
|
+
"--port #{options[:mysql][:port]} " \
|
27
|
+
"-u#{options[:mysql][:username]} " \
|
28
|
+
"-p#{options[:mysql][:password]} " \
|
29
|
+
"#{options[:mysql][:database]} < #{seedfilepath}", exception: true
|
30
|
+
rescue StandardError
|
31
|
+
raise 'Failed to seed integration test db. See README for setup requirements.'
|
39
32
|
end
|
40
33
|
|
41
|
-
def
|
42
|
-
|
43
|
-
reader = get_test_reader options
|
44
|
-
writer = get_test_file_writer options
|
45
|
-
mysql2postgres::Converter.new reader, writer, options
|
34
|
+
def get_test_reader(options)
|
35
|
+
Mysql2postgres::MysqlReader.new options
|
46
36
|
rescue StandardError
|
47
|
-
raise
|
37
|
+
raise 'Failed to initialize integration test db. See README for setup requirements.'
|
48
38
|
end
|
49
39
|
|
50
40
|
def get_temp_file(basename)
|
@@ -54,38 +44,3 @@ def get_temp_file(basename)
|
|
54
44
|
f.close!
|
55
45
|
path
|
56
46
|
end
|
57
|
-
|
58
|
-
def get_new_test_config(include_tables: [], exclude_tables: [], to_file: false,
|
59
|
-
suppress_data: false, suppress_ddl: false, force_truncate: false)
|
60
|
-
|
61
|
-
to_filename = to_file ? get_temp_file(['mysql2postgres_tmp_output_', '.yml']) : nil
|
62
|
-
configtext = Mysql2postgres::Config.template to_filename, include_tables, exclude_tables, suppress_data, suppress_ddl, force_truncate
|
63
|
-
configfile = get_temp_file 'mysql2postgres_tmp_config'
|
64
|
-
File.open(configfile, 'w:UTF-8') { |f| f.write(configtext) }
|
65
|
-
yaml = YAML.load_file configfile
|
66
|
-
Mysql2postgres::ConfigBase.new yaml
|
67
|
-
rescue StandardError
|
68
|
-
raise "Failed to initialize options from #{configfile}. See README for setup requirements."
|
69
|
-
end
|
70
|
-
|
71
|
-
def get_test_config_by_label(name)
|
72
|
-
case name
|
73
|
-
when :localmysql_to_file_convert_nothing
|
74
|
-
get_new_test_config to_file: true,
|
75
|
-
tables: ['unobtainium'],
|
76
|
-
exclude_tables: ['kryptonite'],
|
77
|
-
suppress_data: true,
|
78
|
-
suppress_ddl: true
|
79
|
-
when :localmysql_to_file_convert_all
|
80
|
-
get_new_test_config to_file: true
|
81
|
-
when :localmysql_to_db_convert_all
|
82
|
-
get_new_test_config
|
83
|
-
when :localmysql_to_db_convert_nothing
|
84
|
-
get_new_test_config tables: ['unobtainium'],
|
85
|
-
exclude_tables: ['kryptonite'],
|
86
|
-
suppress_data: true,
|
87
|
-
suppress_ddl: true
|
88
|
-
else
|
89
|
-
raise "Invalid label: #{name}"
|
90
|
-
end
|
91
|
-
end
|
data/test/units/option_test.rb
CHANGED
@@ -4,14 +4,11 @@ require File.expand_path '../test_helper', __dir__
|
|
4
4
|
require 'yaml'
|
5
5
|
|
6
6
|
class SettingTest < Test::Unit::TestCase
|
7
|
-
attr_reader :config_all_opts
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@config_all_opts = YAML.load_file "#{__dir__}/../fixtures/config_all_options.yml"
|
11
|
-
end
|
12
|
-
|
13
7
|
def test_options_loaded
|
14
|
-
|
15
|
-
|
8
|
+
options = options_from_file
|
9
|
+
|
10
|
+
assert_equal false, options[:suppress_data]
|
11
|
+
assert_equal 'postgres', options[:destination][:username]
|
12
|
+
assert_equal 'somename', options[:destination][:database]
|
16
13
|
end
|
17
14
|
end
|
@@ -15,10 +15,12 @@ class PostgresFileWriterTest < Test::Unit::TestCase
|
|
15
15
|
File.delete destfile
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
19
|
-
|
18
|
+
def test_file_writer
|
19
|
+
destination = { filename: '/tmp/test.sql' }
|
20
|
+
writer = Mysql2postgres::PostgresFileWriter.new @destfile, destination
|
20
21
|
writer.close
|
21
22
|
content = File.read destfile
|
23
|
+
|
22
24
|
assert_not_nil content.match("SET client_encoding = 'UTF8'")
|
23
25
|
assert_nil content.match('unobtanium')
|
24
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql2postgres
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Lapshin <max@maxidoors.ru>
|
@@ -24,22 +24,8 @@ authors:
|
|
24
24
|
autorequire:
|
25
25
|
bindir: bin
|
26
26
|
cert_chain: []
|
27
|
-
date:
|
27
|
+
date: 2023-10-14 00:00:00.000000000 Z
|
28
28
|
dependencies:
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: rake
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - ">="
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '0'
|
36
|
-
type: :runtime
|
37
|
-
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '0'
|
43
29
|
- !ruby/object:Gem::Dependency
|
44
30
|
name: pg
|
45
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -55,19 +41,19 @@ dependencies:
|
|
55
41
|
- !ruby/object:Gem::Version
|
56
42
|
version: 1.2.2
|
57
43
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
44
|
+
name: rake
|
59
45
|
requirement: !ruby/object:Gem::Requirement
|
60
46
|
requirements:
|
61
|
-
- - "
|
47
|
+
- - ">="
|
62
48
|
- !ruby/object:Gem::Version
|
63
|
-
version: '0
|
49
|
+
version: '0'
|
64
50
|
type: :runtime
|
65
51
|
prerelease: false
|
66
52
|
version_requirements: !ruby/object:Gem::Requirement
|
67
53
|
requirements:
|
68
|
-
- - "
|
54
|
+
- - ">="
|
69
55
|
- !ruby/object:Gem::Version
|
70
|
-
version: '0
|
56
|
+
version: '0'
|
71
57
|
- !ruby/object:Gem::Dependency
|
72
58
|
name: ruby-mysql
|
73
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,62 +68,6 @@ dependencies:
|
|
82
68
|
- - "~>"
|
83
69
|
- !ruby/object:Gem::Version
|
84
70
|
version: '3.0'
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
name: debug
|
87
|
-
requirement: !ruby/object:Gem::Requirement
|
88
|
-
requirements:
|
89
|
-
- - ">="
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: '0'
|
92
|
-
type: :development
|
93
|
-
prerelease: false
|
94
|
-
version_requirements: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
- - ">="
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: '0'
|
99
|
-
- !ruby/object:Gem::Dependency
|
100
|
-
name: rubocop-minitest
|
101
|
-
requirement: !ruby/object:Gem::Requirement
|
102
|
-
requirements:
|
103
|
-
- - ">="
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version: '0'
|
106
|
-
type: :development
|
107
|
-
prerelease: false
|
108
|
-
version_requirements: !ruby/object:Gem::Requirement
|
109
|
-
requirements:
|
110
|
-
- - ">="
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: '0'
|
113
|
-
- !ruby/object:Gem::Dependency
|
114
|
-
name: rubocop-performance
|
115
|
-
requirement: !ruby/object:Gem::Requirement
|
116
|
-
requirements:
|
117
|
-
- - ">="
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version: '0'
|
120
|
-
type: :development
|
121
|
-
prerelease: false
|
122
|
-
version_requirements: !ruby/object:Gem::Requirement
|
123
|
-
requirements:
|
124
|
-
- - ">="
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
version: '0'
|
127
|
-
- !ruby/object:Gem::Dependency
|
128
|
-
name: test-unit
|
129
|
-
requirement: !ruby/object:Gem::Requirement
|
130
|
-
requirements:
|
131
|
-
- - "~>"
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: 3.5.3
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
requirements:
|
138
|
-
- - "~>"
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: 3.5.3
|
141
71
|
description: Translates MySQL -> PostgreSQL
|
142
72
|
email: a.meindl@alphanodes.com
|
143
73
|
executables:
|
@@ -158,20 +88,22 @@ files:
|
|
158
88
|
- lib/mysql2postgres/postgres_file_writer.rb
|
159
89
|
- lib/mysql2postgres/postgres_writer.rb
|
160
90
|
- lib/mysql2postgres/version.rb
|
161
|
-
- lib/mysql2postgres/writer.rb
|
162
91
|
- mysql2postgres.gemspec
|
163
92
|
- test/fixtures/config_all_options.yml
|
93
|
+
- test/fixtures/config_min_options.yml
|
94
|
+
- test/fixtures/config_to_file.yml
|
164
95
|
- test/fixtures/seed_integration_tests.sql
|
165
96
|
- test/integration/convert_to_db_test.rb
|
166
97
|
- test/integration/convert_to_file_test.rb
|
167
98
|
- test/integration/converter_test.rb
|
168
|
-
- test/integration/
|
99
|
+
- test/integration/mysql_reader_connection_test.rb
|
169
100
|
- test/integration/mysql_reader_test.rb
|
170
|
-
- test/integration/
|
101
|
+
- test/integration/postgres_db_writer_test.rb
|
171
102
|
- test/test_helper.rb
|
103
|
+
- test/units/mysql_test.rb
|
172
104
|
- test/units/option_test.rb
|
173
105
|
- test/units/postgres_file_writer_test.rb
|
174
|
-
homepage: https://
|
106
|
+
homepage: https://github.com/AlphaNodes/mysql2postgres
|
175
107
|
licenses:
|
176
108
|
- MIT
|
177
109
|
metadata:
|
@@ -192,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
124
|
- !ruby/object:Gem::Version
|
193
125
|
version: '0'
|
194
126
|
requirements: []
|
195
|
-
rubygems_version: 3.3.
|
127
|
+
rubygems_version: 3.3.26
|
196
128
|
signing_key:
|
197
129
|
specification_version: 4
|
198
130
|
summary: MySQL to PostgreSQL Data Translation
|