mysqlsyncr 1.1.8 → 1.1.12

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.
package/README.md CHANGED
@@ -1,186 +1,187 @@
1
- # MySQLSyncr
2
-
3
- Warning: Please be careful when using this tool. It is still in development and may not be fully stable. Test on a development database before using on production.
4
-
5
- MySQLSyncr is a command-line tool for managing and comparing MySQL database structures with JSON dumps. It allows users to dump the database structure, compare it with existing JSON files, and update the database based on those JSON definitions.
6
-
7
- ## Table of Contents
8
-
9
- - [Features](#features)
10
- - [Installation](#installation)
11
- - [Global Installation](#global-installation)
12
- - [Local Installation](#local-installation)
13
- - [Usage](#usage)
14
- - [Commands](#commands)
15
- - [Configuration Options](#configuration-options)
16
- - [Using MySQLSyncr as a Module](#using-mysqlsyncr-as-a-module)
17
- - [Contributing](#contributing)
18
- - [License](#license)
19
-
20
- ## Features
21
-
22
- - **Dump**: Export the database structure to JSON files.
23
- - **Compare**: Compare the current database structure with JSON dumps to identify differences.
24
- - **Update**: Update the database structure based on the provided JSON definitions.
25
- - **UI**: Open a web-based database browser interface.
26
- - **Verbose Logging**: Enable detailed logging for debugging purposes.
27
-
28
- ![Database Browser Interface](view.png)
29
-
30
- ## Installation
31
-
32
- ### Global Installation
33
-
34
- To install MySQLSync globally, allowing you to use it from the command line, run the following command:
35
-
36
- ```bash
37
- npm install -g mysqlsyncr
38
- ```
39
-
40
- This will allow you to run the command as `mysqlsyncr` from anywhere in your terminal.
41
-
42
- ### Local Installation
43
-
44
- If you prefer to use MySQLSyncr locally within a project, you can install it as a dependency:
45
-
46
- ```bash
47
- npm install mysqlsyncr
48
- ```
49
-
50
- This will add MySQLSyncr to your project's `node_modules` and allow you to use it within your project.
51
-
52
- ## Usage
53
-
54
- You can run MySQLSync commands using the following syntax:
55
-
56
- ```bash
57
- mysqlsyncr <command> [options]
58
- ```
59
-
60
- ### Commands
61
-
62
- - `dump`: Dumps the database structure to files.
63
- - `compare`: Compares the database structure with JSON dumps (dry run).
64
- - `update`: Updates the database structure based on JSON dumps.
65
- - `ui`: Opens a web-based database browser in your default system browser.
66
-
67
- ### Configuration Options
68
-
69
- You can configure the following options when running the commands:
70
-
71
- | Option | Alias | Description | Default Value |
72
- |-------------|-------|-----------------------------------------------------------------------------|--------------------------------|
73
- | `uiPort` | `-U` | UI port | `3600` |
74
- | `openUI` | `-O` | Open UI in default browser (boolean) | `true` |
75
- | `host` | `-h` | Database host | `localhost` |
76
- | `port` | `-P` | Database port | `3306` |
77
- | `user` | `-u` | Database user | `root` |
78
- | `password` | `-p` | Database password (required) | |
79
- | `database` | `-d` | Target database | `null` |
80
- | `output` | `-o` | Output directory for dumping. Default is one level up from the current directory in a new folder called `db-dump` | `../db-dump` |
81
- | `verbose` | `-v` | Enable verbose logging (boolean) | `false` |
82
-
83
- ### Example Usage
84
-
85
- 1. **Dump the database structure**:
86
- ```bash
87
- mysqlsyncr dump --host localhost --user root --password yourpassword
88
- ```
89
-
90
- 2. **Compare the database structure with JSON dumps**:
91
- ```bash
92
- mysqlsyncr compare --host localhost --user root --password yourpassword
93
- ```
94
-
95
- 3. **Update the database structure based on JSON dumps**:
96
- ```bash
97
- mysqlsyncr update --host localhost --user root --password yourpassword
98
- ```
99
-
100
- 4. **Open the database browser interface**:
101
- ```bash
102
- mysqlsyncr ui --host localhost --user root --password yourpassword
103
- ```
104
-
105
- ## Using MySQLSync as a Module
106
-
107
- If you want to use MySQLSync as a module in your own Node.js application, you can require it in your code:
108
-
109
- ```javascript
110
- import mysqlsyncr from 'mysqlsyncr';
111
-
112
- // Example usage
113
- const config = {
114
- host: 'localhost',
115
- user: 'root',
116
- password: 'yourpassword',
117
- database: 'yourdatabase'
118
- };
119
- ```
120
-
121
- ```javascript
122
- // app.js
123
- import mysqlsyncr from 'mysqlsyncr';
124
- import fs from 'fs';
125
- import path from 'path';
126
-
127
- // Database configuration
128
- const config = {
129
- host: 'localhost',
130
- user: 'root',
131
- password: 'yourpassword',
132
- database: 'yourdatabase'
133
- };
134
-
135
- // Function to dump the database structure
136
- async function dumpDatabase() {
137
- try {
138
- console.log('Dumping the database structure...');
139
- await mysqlsyncr.dump(config);
140
- console.log('Database structure dumped successfully.');
141
- } catch (error) {
142
- console.error('Error dumping database:', error.message);
143
- }
144
- }
145
-
146
- // Function to compare the database structure with JSON dumps
147
- async function compareDatabase() {
148
- try {
149
- const inputDir = path.join(__dirname, 'db-dump'); // Directory where JSON dumps are stored
150
- console.log('Comparing the database structure with JSON dumps...');
151
- const differences = await mysqlsyncr.compare(config, inputDir);
152
-
153
- if (differences.length > 0) {
154
- console.log('Differences found:');
155
- console.log(differences);
156
- } else {
157
- console.log('No differences found. The database structure matches the JSON dumps.');
158
- }
159
- } catch (error) {
160
- console.error('Error comparing database:', error.message);
161
- }
162
- }
163
-
164
- // Main function to execute dump and compare
165
- (async () => {
166
- await dumpDatabase();
167
- await compareDatabase();
168
- })();
169
- ```
170
-
171
- Make sure to check the source code for available functions and their usage.
172
-
173
- ## Contributing
174
-
175
- Contributions are welcome! If you would like to contribute to MySQLSyncr, please follow these steps:
176
-
177
- 1. Fork the repository.
178
- 2. Create a new branch for your feature or bug fix.
179
- 3. Make your changes and commit them with clear messages.
180
- 4. Push your changes to your forked repository.
181
- 5. Open a pull request to the main repository.
182
-
183
-
184
- ## License
185
-
186
- This project is licensed under the ISC License. See the [LICENSE](LICENSE) file for more details.
1
+ # MySQLSyncr
2
+
3
+ Warning: Please be careful when using this tool. It is still in development and may not be fully stable. Test on a development database before using on production.
4
+
5
+ MySQLSyncr is a command-line tool for managing and comparing MySQL database structures with JSON dumps. It allows users to dump the database structure, compare it with existing JSON files, and update the database based on those JSON definitions.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Features](#features)
10
+ - [Installation](#installation)
11
+ - [Global Installation](#global-installation)
12
+ - [Local Installation](#local-installation)
13
+ - [Usage](#usage)
14
+ - [Commands](#commands)
15
+ - [Configuration Options](#configuration-options)
16
+ - [Using MySQLSyncr as a Module](#using-mysqlsyncr-as-a-module)
17
+ - [Contributing](#contributing)
18
+ - [License](#license)
19
+
20
+ ## Features
21
+
22
+ - **Dump**: Export the database structure to JSON files.
23
+ - **Compare**: Compare the current database structure with JSON dumps to identify differences.
24
+ - **Update**: Update the database structure based on the provided JSON definitions.
25
+ - **UI**: Open a web-based database browser interface.
26
+ - **Verbose Logging**: Enable detailed logging for debugging purposes.
27
+
28
+ ![Database Browser Interface](view.png)
29
+
30
+ ## Installation
31
+
32
+ ### Global Installation
33
+
34
+ To install MySQLSync globally, allowing you to use it from the command line, run the following command:
35
+
36
+ ```bash
37
+ npm install -g mysqlsyncr
38
+ ```
39
+
40
+ This will allow you to run the command as `mysqlsyncr` from anywhere in your terminal.
41
+
42
+ ### Local Installation
43
+
44
+ If you prefer to use MySQLSyncr locally within a project, you can install it as a dependency:
45
+
46
+ ```bash
47
+ npm install mysqlsyncr
48
+ ```
49
+
50
+ This will add MySQLSyncr to your project's `node_modules` and allow you to use it within your project.
51
+
52
+ ## Usage
53
+
54
+ You can run MySQLSync commands using the following syntax:
55
+
56
+ ```bash
57
+ mysqlsyncr <command> [options]
58
+ ```
59
+
60
+ ### Commands
61
+
62
+ - `dump`: Dumps the database structure to files.
63
+ - `compare`: Compares the database structure with JSON dumps (dry run).
64
+ - `update`: Updates the database structure based on JSON dumps.
65
+ - `ui`: Opens a web-based database browser in your default system browser.
66
+
67
+ ### Configuration Options
68
+
69
+ You can configure the following options when running the commands:
70
+
71
+ | Option | Alias | Description | Default Value |
72
+ |-------------|-------|-----------------------------------------------------------------------------|--------------------------------|
73
+ | `uiPort` | `-U` | UI port | `3600` |
74
+ | `openUI` | `-O` | Open UI in default browser (boolean) | `true` |
75
+ | `host` | `-h` | Database host | `localhost` |
76
+ | `port` | `-P` | Database port | `3306` |
77
+ | `user` | `-u` | Database user | `root` |
78
+ | `password` | `-p` | Database password (required) | |
79
+ | `database` | `-d` | Target database | `null` |
80
+ | `output` | `-o` | Output directory for dumping. Default is one level up from the current directory in a new folder called `db-dump` | `../db-dump` |
81
+ | `verbose` | `-v` | Enable verbose logging (boolean) | `false` |
82
+
83
+ ### Example Usage
84
+
85
+ 1. **Dump the database structure**:
86
+ ```bash
87
+ mysqlsyncr dump --host localhost --user root --password yourpassword
88
+ ```
89
+
90
+ 2. **Compare the database structure with JSON dumps**:
91
+ ```bash
92
+ mysqlsyncr compare --host localhost --user root --password yourpassword
93
+ ```
94
+
95
+ 3. **Update the database structure based on JSON dumps**:
96
+ ```bash
97
+ mysqlsyncr update --host localhost --user root --password yourpassword
98
+ ```
99
+
100
+ 4. **Open the database browser interface**:
101
+ *Note: This does not work with PowerShell. Must use Command Prompt in windows*
102
+ ```bash
103
+ mysqlsyncr ui --host localhost --user root --password yourpassword
104
+ ```
105
+
106
+ ## Using MySQLSync as a Module
107
+
108
+ If you want to use MySQLSync as a module in your own Node.js application, you can require it in your code:
109
+
110
+ ```javascript
111
+ import mysqlsyncr from 'mysqlsyncr';
112
+
113
+ // Example usage
114
+ const config = {
115
+ host: 'localhost',
116
+ user: 'root',
117
+ password: 'yourpassword',
118
+ database: 'yourdatabase'
119
+ };
120
+ ```
121
+
122
+ ```javascript
123
+ // app.js
124
+ import mysqlsyncr from 'mysqlsyncr';
125
+ import fs from 'fs';
126
+ import path from 'path';
127
+
128
+ // Database configuration
129
+ const config = {
130
+ host: 'localhost',
131
+ user: 'root',
132
+ password: 'yourpassword',
133
+ database: 'yourdatabase'
134
+ };
135
+
136
+ // Function to dump the database structure
137
+ async function dumpDatabase() {
138
+ try {
139
+ console.log('Dumping the database structure...');
140
+ await mysqlsyncr.dump(config);
141
+ console.log('Database structure dumped successfully.');
142
+ } catch (error) {
143
+ console.error('Error dumping database:', error.message);
144
+ }
145
+ }
146
+
147
+ // Function to compare the database structure with JSON dumps
148
+ async function compareDatabase() {
149
+ try {
150
+ const inputDir = path.join(__dirname, 'db-dump'); // Directory where JSON dumps are stored
151
+ console.log('Comparing the database structure with JSON dumps...');
152
+ const differences = await mysqlsyncr.compare(config, inputDir);
153
+
154
+ if (differences.length > 0) {
155
+ console.log('Differences found:');
156
+ console.log(differences);
157
+ } else {
158
+ console.log('No differences found. The database structure matches the JSON dumps.');
159
+ }
160
+ } catch (error) {
161
+ console.error('Error comparing database:', error.message);
162
+ }
163
+ }
164
+
165
+ // Main function to execute dump and compare
166
+ (async () => {
167
+ await dumpDatabase();
168
+ await compareDatabase();
169
+ })();
170
+ ```
171
+
172
+ Make sure to check the source code for available functions and their usage.
173
+
174
+ ## Contributing
175
+
176
+ Contributions are welcome! If you would like to contribute to MySQLSyncr, please follow these steps:
177
+
178
+ 1. Fork the repository.
179
+ 2. Create a new branch for your feature or bug fix.
180
+ 3. Make your changes and commit them with clear messages.
181
+ 4. Push your changes to your forked repository.
182
+ 5. Open a pull request to the main repository.
183
+
184
+
185
+ ## License
186
+
187
+ This project is licensed under the ISC License. See the [LICENSE](LICENSE) file for more details.