Skip to content

Commit ce18739

Browse files
author
AnatolyUss
committed
Merge branch 'feature/nmig_3'
2 parents 620d00b + 58eaa76 commit ce18739

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+731
-777
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
node_modules
3+
logs_directory
4+
temporary_directory

README.md

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ from MySQL to PostgreSQL as easy and smooth as possible.</p>
2323

2424
<h3>SYSTEM REQUIREMENTS</h3>
2525
<ul>
26-
<li> <b>Node.js 5 or higher</b></li>
26+
<li> <b>Node.js 7 or higher</b></li>
2727
</ul>
2828

2929
<h3>USAGE</h3>
@@ -44,11 +44,11 @@ from MySQL to PostgreSQL as easy and smooth as possible.</p>
4444
&nbsp;&nbsp;&nbsp;&nbsp;<b>Sample:</b><br />
4545
<pre>$ cd /path/to/nmig</pre><br />
4646
<pre>$ npm install</pre><br />
47-
<pre>$ node nmig.js</pre><br />
47+
<pre>$ npm start</pre><br />
4848
</p>
4949

5050
<p><b>5.</b> If a disaster took place during migration (for what ever reason) - simply restart the process
51-
<code>$ node nmig.js</code><br>&nbsp;&nbsp;&nbsp;&nbsp;NMIG will restart from the point it was stopped at.
51+
<code>$ npm start</code><br>&nbsp;&nbsp;&nbsp;&nbsp;NMIG will restart from the point it was stopped at.
5252
</p>
5353

5454
<p><b>6.</b> At the end of migration check log files, if necessary.<br />&nbsp;&nbsp;&nbsp;
@@ -61,23 +61,9 @@ from MySQL to PostgreSQL as easy and smooth as possible.</p>
6161
<a href="mailto:[email protected]?subject=NMIG">[email protected]</a></p>
6262

6363
<h3>VERSION</h3>
64-
<p>Current version is 2.6.1<br />
64+
<p>Current version is 3.0.0<br />
6565
(major version . improvements . bug fixes)</p>
6666

67-
68-
<h3>TEST</h3>
69-
<p>Tested using MySQL Community Server (5.7.17) and PostgreSQL (9.5).<br />
70-
The entire process of migration 59.9 MB database (53 tables, 581275 rows),<br />
71-
which includes data types mapping, creation of tables, constraints, indexes, <br />
72-
PKs, FKs, migration of data, garbage-collection (VACUUM) and analyzing the newly created <br />
73-
PostgreSQL database took 1 minute 2 seconds.</p>
74-
<p>
75-
<b>Note:</b>&nbsp; it is highly recommended to VACUUM newly created database! <br />
76-
Just keep in mind, that VACUUM is a very time-consuming procedure. <br />
77-
So if you are short in time - disable VACUUM via config.json ("no_vacuum" parameter). <br />
78-
Such step will save you ~25% of migration time. <br />
79-
</p>
80-
8167
<h3>REMARKS</h3>
8268
<p>Errors/Exceptions are not passed silently.<br />
8369
Any error will be immediately written into the error log file.</p>

config.json

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
{
2+
"README" : [
3+
"This JSON document represents the main configuration options.",
4+
"Please, be mindful, read each option's description before setting its value."
5+
],
6+
27
"source_description" : [
38
"Connection parameters to your MySQL database",
49
"Please ensure, that you have defined all parameters properly.",
@@ -13,11 +18,6 @@
1318
"password" : "0123456789"
1419
},
1520

16-
"max_pool_size_source_description" : [
17-
"Maximal amount of simultaneous connections to your MySQL database during migration"
18-
],
19-
"max_pool_size_source" : 10,
20-
2121
"target_description" : [
2222
"Connection parameters to your PostgreSQL database",
2323
"Please ensure, that you have defined all parameters properly.",
@@ -32,28 +32,19 @@
3232
"password" : "0123456789"
3333
},
3434

35-
"max_pool_size_target_description" : [
36-
"Maximal amount of simultaneous connections to your PostgreSQL database during migration"
35+
"max_db_connection_pool_size_description" : [
36+
"Maximal amount of simultaneous connections to your MySQL and PostgreSQL servers.",
37+
"For example: 10 means, that nmig will create a pool of 10 connections to MySQL server",
38+
"and 10 connections to PostgreSQL server.",
39+
"20 connections to both servers."
3740
],
38-
"max_pool_size_target" : 10,
39-
40-
"pipe_width_description" : [
41-
"Maximal amount of data-chunks, processed in a single 'DataPipe' iteration.",
42-
"Note: 'pipe_width' should not be greater than 'max_pool_size_target'."
43-
],
44-
"pipe_width" : 10,
45-
46-
"max_loader_processes_description" : [
47-
"Each 'DataPipe' iteration processed by a separate process (o.s. thread).",
48-
"max_loader_processes is a maximal amount of simultaneously running loader processes.",
49-
"If not supplied, then max_loader_processes will be equals to one."
50-
],
51-
"max_loader_processes" : 1,
41+
"max_db_connection_pool_size" : 10,
5242

5343
"loader_max_old_space_size_description" : [
5444
"V8 memory limit of the loader process.",
55-
"Possible values are: any number, representing memory limit (in MB),",
56-
"or DEFAULT, representing V8 default limit for your current hardware."
45+
"Possible values are:",
46+
"1. any number, representing memory limit (in MB).",
47+
"2. 'DEFAULT', representing V8 default memory limit for your current hardware."
5748
],
5849
"loader_max_old_space_size" : "DEFAULT",
5950

@@ -64,19 +55,20 @@
6455
"encoding" : "utf8",
6556

6657
"schema_description" : [
67-
"schema - a name of the schema, that will contain all migrated tables.",
58+
"A name of the schema, that will contain all migrated tables.",
6859
"If not supplied, then a new schema will be created automatically."
6960
],
7061
"schema" : "public",
7162

7263
"data_chunk_size_description" : [
73-
"During migration each table's data will be split into chunks of data_chunk_size (in MB).",
74-
"If not supplied, then 1 MB will be used as a default."
64+
"During migration each table's data will be split into chunks not larger than data_chunk_size (in MB).",
65+
"If not supplied, then 10 MB will be used as a default."
7566
],
76-
"data_chunk_size" : 1,
67+
"data_chunk_size" : 10,
7768

7869
"no_vacuum_description" : [
79-
"PostgreSQL VACUUM reclaims storage occupied by dead tuples. VACUUM is a very time-consuming procedure.",
70+
"PostgreSQL VACUUM reclaims storage occupied by dead tuples.",
71+
"VACUUM is a very time-consuming procedure.",
8072
"By default, VACUUM will be performed automatically after migration (recommended)",
8173
"This behavior can be disabled for tables, included into the list (Array) below.",
8274
"Table names, included into the list below should be names, you use in your source database (MySQL)."
@@ -96,14 +88,15 @@
9688
"migrate_only_data" : false,
9789

9890
"delimiter_description" : [
99-
"Specifies the character that separates columns within each record.",
91+
"Specifies the character, that separates columns within each record.",
10092
"This must be a single one-byte character.",
10193
"The default is comma."
10294
],
10395
"delimiter" : ",",
10496

10597
"enable_extra_config_description" : [
106-
"In order to enable the additional configuration options - set this parameter true."
98+
"In order to enable the additional configuration options, placed at extra_config.json",
99+
" - set this parameter true."
107100
],
108101
"enable_extra_config" : false
109102
}
File renamed without changes.

extra_config.json

Lines changed: 70 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
{
22
"README" : [
33
"This JSON document represents an additional configuration options.",
4-
"These options (currently only renaming) will be applied during migration if, and only if",
4+
"Currently, following options are available:",
5+
"1. tables and columns renaming 'on the fly'.",
6+
"2. generating foreign keys 'on the fly'.",
7+
"These options will be applied during migration if, and only if",
58
"the 'enable_extra_config' attribute from 'config.json' is set true.",
69
"By default the 'enable_extra_config' is false, hence the options",
7-
"described here will not take effect.",
10+
"described here will not take effect."
11+
],
12+
13+
"README_RENAMING" : [
814
"Following lines are an example of expected renaming format.",
9-
"Feel free to modify them."
15+
"Feel free to modify them.",
16+
"Note, the 'name' attribute is mandatory.",
17+
"'columns' attribute is optional.",
18+
"If you don't need to rename columns, then remove the 'columns' attribute.",
19+
"If you don't need to rename tables,",
20+
"then set both 'name' object's attributes ('original' and 'new') to an actual table's name.",
21+
"If you don't need to rename neither tables nor columns, then remove the 'tables' section."
1022
],
1123

1224
"tables" : [
@@ -28,16 +40,16 @@
2840
},
2941

3042
{
31-
"original" : "password",
32-
"new" : "renamed_password"
43+
"original" : "group_id",
44+
"new" : "renamed_group_id"
3345
}
3446
]
3547
},
3648

3749
{
3850
"name" : {
39-
"original" : "logs",
40-
"new" : "renamed_logs"
51+
"original" : "groups",
52+
"new" : "renamed_groups"
4153
},
4254

4355
"columns" : [
@@ -47,5 +59,56 @@
4759
}
4860
]
4961
}
62+
],
63+
64+
"README_FKs" : [
65+
"Following lines are an example of expected foreign keys format.",
66+
"Feel free to modify them.",
67+
"Note, if one of the following: 'column_name', 'referenced_table_name', 'referenced_column_name'",
68+
"has being renamed, then a new name must be used.",
69+
"Note, possible values for 'update_rule' and 'delete_rule' are 'restrict' or 'cascade'.",
70+
"If you don't need to create foreign keys 'on the fly', then remove the 'foreign_keys' section."
71+
],
72+
73+
"foreign_keys" : [
74+
{
75+
"constraint_name" : "renamed_admins_renamed_group_id_foreign",
76+
"table_name" : "renamed_admins",
77+
"column_name" : "renamed_group_id",
78+
"referenced_table_name" : "renamed_groups",
79+
"referenced_column_name" : "renamed_id",
80+
"update_rule" : "restrict",
81+
"delete_rule" : "restrict"
82+
},
83+
84+
{
85+
"constraint_name" : "logs_test_3_merchant_id_foreign",
86+
"table_name" : "logs_test_3",
87+
"column_name" : "merchant_id",
88+
"referenced_table_name" : "merchants",
89+
"referenced_column_name" : "id",
90+
"update_rule" : "restrict",
91+
"delete_rule" : "cascade"
92+
},
93+
94+
{
95+
"constraint_name" : "composite_foreign_key_example",
96+
"table_name" : "loGs_Test-6",
97+
"column_name" : "id1",
98+
"referenced_table_name" : "logs_test_4",
99+
"referenced_column_name" : "id1",
100+
"update_rule" : "cascade",
101+
"delete_rule" : "cascade"
102+
},
103+
104+
{
105+
"constraint_name" : "composite_foreign_key_example",
106+
"table_name" : "loGs_Test-6",
107+
"column_name" : "id2",
108+
"referenced_table_name" : "logs_test_4",
109+
"referenced_column_name" : "id2",
110+
"update_rule" : "cascade",
111+
"delete_rule" : "cascade"
112+
}
50113
]
51114
}

migration/fmtp/Conversion.js

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)