1
1
# node-mysql-migrate
2
2
3
+ ## Table of Contents
4
+
5
+ - [ Overview] ( #overview )
6
+ - [ Installation] ( #installation )
7
+ - [ Command line] ( #command-line )
8
+ - [ baseline] ( #baseline )
9
+ - [ info] ( #info )
10
+ - [ migrate] ( #migrate )
11
+ - [ repair] ( #repair )
12
+ - [ clean] ( #clean )
13
+ - [ Writing a migration script] ( #writing-a-migration-script )
14
+ - [ Data Directory] ( #data-directory )
15
+ - [ Naming] ( #naming )
16
+ - [ SQL] ( #sql )
17
+ - [ Node.js] ( #nodejs )
18
+ - [ Using the library] ( #using-the-library-directly )
19
+ - [ Configuration] ( #configuration )
20
+
21
+
3
22
## Overview
4
- Simple migration tool for Mysql/Node.js
5
23
6
- # Quick Start
24
+ Simple MySQL migration tool written in Node.js. MIT License.
25
+
26
+ ## Quick Start
7
27
8
- #### Install
28
+ #### Installation
9
29
10
30
``` sh
11
31
npm install -g https://github.com/talmago/node-mysql-migrate
12
32
```
13
33
14
- After the installation, you can start using the command line as well as the library .
15
-
34
+ > ** NOTICE: ** -g flag is mandatory if you wish to use the command line .
35
+ Use ` npm install https://github.com/talmago/node-mysql-migrate ` if you want to use the library.
16
36
17
37
#### Command line
18
38
@@ -238,7 +258,7 @@ Examples:
238
258
239
259
# ##### SQL
240
260
241
- Writing migration script in SQL is pretty straight-forward, as it used the standard
261
+ Writing migration script in SQL is pretty straight-forward, as it uses the standard
242
262
MySQL programming (http://dev.mysql.com/doc/refman/5.7/en/sql-syntax.html). Below is
243
263
a simple example which created a new table in our project called ` users` .
244
264
@@ -276,6 +296,27 @@ module.exports = function(connection) {
276
296
Node.js modules should not start or end a new transaction, as these operations are expected to raise
277
297
runtime errors as well.
278
298
299
+ # ### Using the library directly
300
+
301
+ ` ` ` javascript
302
+
303
+ var SchemaManager = require(' node-mysql-migrate' ).SchemaManager;
304
+
305
+ var mgr = new SchemaManager(' myproject' , {
306
+ .. config ..
307
+ });
308
+
309
+ mgr.migrate(' /path/to/data/directory' )
310
+ .then(function () {
311
+ // .. post-migration code ..
312
+ })
313
+ .catch(function(e) {
314
+ console.error(e.message);
315
+ })
316
+ .finally(function () {
317
+ mgr.close ();
318
+ })
319
+ ` ` `
279
320
280
321
# ### Configuration
281
322
@@ -295,7 +336,7 @@ Configuration should be in one of the following formats:
295
336
* INI
296
337
* JSON
297
338
298
- # # INI (example)
339
+ # ##### INI
299
340
300
341
` ` `
301
342
[logging]
@@ -312,8 +353,7 @@ schema = myproject
312
353
datadir = /etc/mysql-migraterc/data
313
354
` ` `
314
355
315
-
316
- # # JSON (example)
356
+ # ##### JSON
317
357
318
358
` ` ` javascript
319
359
{
0 commit comments