mysql2postgres 0.4.0 → 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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1108264fc3155986e78c07a12abd11c6ef39a1fb671a252e6921bf4bbf7f3a4b
|
4
|
+
data.tar.gz: 19837bf3a64bf6a204c9325b1271566e982467f7a3e9a53f966681c8a680e1ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e5c54b071adaa63e1bfa5819fcadc7520f1063a4a0d2218adb5337361df259ddf574ab37bec2bc7f7683a0c4024679fd87c6d6715fe692a56768365cb5021a71
|
7
|
+
data.tar.gz: 992c22cdfa9e8ebea90fdecb10f95a00367b3ba9cd744c6cb0d954a0a2be81138376319a7f657337e8a50b83cd4969e577e7b6de480369e34edd1b9dcc8697e6
|
@@ -27,7 +27,7 @@ class Mysql2postgres
|
|
27
27
|
|
28
28
|
def convert
|
29
29
|
tables = reader.tables
|
30
|
-
tables.reject! { |table| exclude_tables.include?
|
30
|
+
tables.reject! { |table| exclude_tables.include? table.name }
|
31
31
|
tables.select! { |table| only_tables ? only_tables.include?(table.name) : true }
|
32
32
|
|
33
33
|
# preserve order only works, if only_tables are specified
|
@@ -125,7 +125,7 @@ class Mysql2postgres
|
|
125
125
|
@indexes << index
|
126
126
|
elsif (match_data = /PRIMARY KEY .*\((.*)\)/.match(line))
|
127
127
|
index[:primary] = true
|
128
|
-
index[:columns] = match_data[1].split(',').map { |col| col.strip.delete
|
128
|
+
index[:columns] = match_data[1].split(',').map { |col| col.strip.delete '`' }
|
129
129
|
@indexes << index
|
130
130
|
end
|
131
131
|
end
|
@@ -216,7 +216,7 @@ class Mysql2postgres
|
|
216
216
|
end
|
217
217
|
|
218
218
|
def tables
|
219
|
-
@tables ||= @mysql.query('SHOW TABLES').map { |row| Table.new
|
219
|
+
@tables ||= @mysql.query('SHOW TABLES').map { |row| Table.new self, row.first }
|
220
220
|
end
|
221
221
|
|
222
222
|
def paginated_read(table, page_size)
|
@@ -51,7 +51,7 @@ class Mysql2postgres
|
|
51
51
|
when 'double precision'
|
52
52
|
default = " DEFAULT #{column[:default].nil? ? 'NULL' : column[:default]}" if default
|
53
53
|
'double precision'
|
54
|
-
when 'datetime'
|
54
|
+
when 'datetime', 'datetime(6)'
|
55
55
|
default = nil
|
56
56
|
'timestamp without time zone'
|
57
57
|
when 'date'
|
@@ -102,14 +102,14 @@ class Mysql2postgres
|
|
102
102
|
if column_type(column) == 'boolean'
|
103
103
|
row[index] = if row[index] == 1
|
104
104
|
't'
|
105
|
-
elsif row[index]
|
105
|
+
elsif row[index]&.zero?
|
106
106
|
'f'
|
107
107
|
else
|
108
108
|
row[index]
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
-
row[index] = string_data row, index, column if row[index].is_a? String
|
112
|
+
row[index] = string_data table, row, index, column if row[index].is_a? String
|
113
113
|
|
114
114
|
row[index] = '\N' unless row[index]
|
115
115
|
end
|
@@ -137,7 +137,7 @@ class Mysql2postgres
|
|
137
137
|
value.join ':'
|
138
138
|
end
|
139
139
|
|
140
|
-
def string_data(row, index, column)
|
140
|
+
def string_data(table, row, index, column)
|
141
141
|
if column_type(column) == 'bytea'
|
142
142
|
if column[:name] == 'data'
|
143
143
|
with_gzip = false
|
@@ -153,16 +153,16 @@ class Mysql2postgres
|
|
153
153
|
escape_bytea row[index]
|
154
154
|
end
|
155
155
|
else
|
156
|
-
escape_data(row[index]).gsub(
|
156
|
+
escape_data(row[index]).gsub("\n", '\n').gsub("\t", '\t').gsub("\r", '\r').gsub(/\0/, '')
|
157
157
|
end
|
158
158
|
end
|
159
159
|
|
160
160
|
def escape_bytea(data)
|
161
|
-
escape_data(PG::Connection.escape_bytea(data)).gsub(
|
161
|
+
escape_data(PG::Connection.escape_bytea(data)).gsub("''", "'")
|
162
162
|
end
|
163
163
|
|
164
164
|
def escape_data(value)
|
165
|
-
value.gsub
|
165
|
+
value.gsub '\\', '\\\\\\'
|
166
166
|
end
|
167
167
|
end
|
168
168
|
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.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Max Lapshin <max@maxidoors.ru>
|
@@ -24,7 +24,7 @@ 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
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: pg
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
rubygems_version: 3.3.
|
127
|
+
rubygems_version: 3.3.26
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: MySQL to PostgreSQL Data Translation
|