mysql-migration 1.2.3 → 1.2.4

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.
Files changed (2) hide show
  1. package/README.md +118 -28
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,25 +1,73 @@
1
- # MySQL Migration Database
1
+ <div align="center">
2
2
 
3
- A simple command-line tool for generating and running database migrations for MySQL.
3
+ # 🗄️ MySQL Migration Database
4
4
 
5
- ## Installation
5
+ **A command-line companion that helps you manage versioned MySQL schema changes from your Node.js projects.**
6
6
 
7
- You can install `mysql-migration` using npm: `npm install mysql-migration`
7
+ [![npm version](https://img.shields.io/npm/v/mysql-migration.svg?style=flat-square)](https://www.npmjs.com/package/mysql-migration)&nbsp;&nbsp;
8
+ [![License](https://img.shields.io/badge/license-Custom-blue.svg?style=flat-square)](LICENSE.md)&nbsp;&nbsp;
9
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D16-brightgreen.svg?style=flat-square)](https://nodejs.org/)
8
10
 
9
- ### Initialize the migrations table
11
+ </div>
10
12
 
11
- If you have not yet run any migrations, you need to initialize the migrations table by running the following command: `npx mysql-migration init`
13
+ ---
12
14
 
13
- <br>
15
+ ## ✨ Features
14
16
 
15
- ## Configuration
17
+ - 🎯 **Multi-database support** — Orchestrate migrations across different environments
18
+ - ⏱️ **Timestamped migration files** — Generated with a single command
19
+ - ⚡ **Forward and backward execution** — Run or roll back batches confidently
20
+ - 🔧 **Scriptable CLI** — Plugs into CI/CD pipelines via standard Node.js tooling
21
+ - 📦 **Zero dependencies** — Lightweight and fast
16
22
 
17
- The configuration file `mysql-migration.config.json` should export an object with the following properties:
23
+ ## 📋 Prerequisites
18
24
 
19
- - `host`: the MySQL server host
20
- - `database`: the name of the database to migrate
21
- - `user`: the MySQL user name
22
- - `password`: the MySQL user password
25
+ - **Node.js** v16 or later.
26
+ - **MySQL** instance reachable from where you run the CLI.
27
+ - A project workspace where you can store migration files and configuration.
28
+
29
+ ## 📦 Installation
30
+
31
+ Install locally within your project:
32
+
33
+ ```bash
34
+ npm install --save-dev mysql-migration
35
+ ```
36
+
37
+ Or run ad hoc without installing by prefixing commands with `npx`.
38
+
39
+ ## 🚀 Quick Start
40
+
41
+ **1️⃣ Create a configuration file**
42
+
43
+ Create `mysql-migration.config.json` in your project root (see [Configuration](#%EF%B8%8F-configuration)).
44
+
45
+ **2️⃣ Initialize the migrations table**
46
+
47
+ ```bash
48
+ npx mysql-migration init
49
+ ```
50
+
51
+ **3️⃣ Generate your first migration**
52
+
53
+ ```bash
54
+ npx mysql-migration create add_users_table main-db
55
+ ```
56
+
57
+ **4️⃣ Apply pending migrations**
58
+
59
+ ```bash
60
+ npx mysql-migration run main-db
61
+ ```
62
+
63
+ ## ⚙️ Configuration
64
+
65
+ The CLI reads settings from `mysql-migration.config.json`. Define each database you manage inside the `databases` object. Every entry requires the connection credentials documented below:
66
+
67
+ - `host`: MySQL server host name or IP.
68
+ - `database`: Database schema name.
69
+ - `user`: User with migration privileges.
70
+ - `password`: Corresponding password.
23
71
 
24
72
  ```json
25
73
  {
@@ -34,29 +82,71 @@ The configuration file `mysql-migration.config.json` should export an object wit
34
82
  }
35
83
  ```
36
84
 
37
- <br>
85
+ Add as many database entries as you need. You can then target each one via the CLI commands below.
86
+
87
+ ## 📖 Usage
88
+
89
+ ### 📝 Available Commands
90
+
91
+ | Command | Description |
92
+ |---------|-------------|
93
+ | `npx mysql-migration help` | 📚 Show all available commands |
94
+ | `npx mysql-migration init` | 🎬 Initialize the migrations table |
95
+ | `npx mysql-migration create <name> <dbName>` | ✏️ Scaffold a timestamped migration file |
96
+ | `npx mysql-migration run [dbName]` | ▶️ Execute all pending migrations |
97
+ | `npx mysql-migration rollback <dbName> <batch>` | ⏪ Roll back migrations to specified batch |
98
+ | `npx mysql-migration batch <dbName>` | 📊 Display recorded batches |
99
+
100
+ ### ✏️ Create a New Migration
101
+
102
+ ```bash
103
+ npx mysql-migration create migration-name database-name
104
+ ```
105
+
106
+ A new file appears in the `migrations/` directory, timestamped and ready for your SQL `up` and `down` statements.
107
+
108
+ ### ▶️ Run Pending Migrations
109
+
110
+ ```bash
111
+ npx mysql-migration run database-name
112
+ ```
113
+
114
+ All migrations that have not yet been applied will run sequentially for the selected database.
115
+
116
+ ### ⏪ Roll Back Migrations
117
+
118
+ ```bash
119
+ npx mysql-migration rollback database-name batch
120
+ ```
121
+
122
+ Use this when you need to revert the database state to the specified batch number.
123
+
124
+ ### 📊 Inspect Batches
125
+
126
+ ```bash
127
+ npx mysql-migration batch database-name
128
+ ```
38
129
 
39
- ## Usage
130
+ View the recorded batches to understand which migrations were executed together.
40
131
 
41
- ### Create a new migration
132
+ ## 🔧 Troubleshooting
42
133
 
43
- To create a new migration, run the following command:\
44
- &emsp;`npx mysql-migration create migration-name database-name`
134
+ - **Authentication errors**: Verify credentials in `mysql-migration.config.json` match your MySQL user.
135
+ - **Connection refused**: Ensure the MySQL server accepts remote connections from your host and the port is open.
136
+ - **Missing migrations folder**: Run `npx mysql-migration init` to scaffold the `migrations/` directory and configuration file.
45
137
 
46
- This will create a new migration file in the `migrations` directory with a timestamp and the name `migration-name`.
138
+ ## 💬 Support
47
139
 
48
- ### Running migrations
140
+ Use `npx mysql-migration help` to review commands, or open an issue on the repository if you encounter bugs or have enhancement ideas.
49
141
 
50
- To run pending migrations, run the following command:\
51
- &emsp;`npx mysql-migration run database-name(optional)`
142
+ ---
52
143
 
53
- This will run all migrations that have not yet been run.
144
+ <div align="center">
54
145
 
55
- ### Rolling back migrations
146
+ ### 📄 License
56
147
 
57
- To roll back the last migration, run the following command:\
58
- &emsp;`npx mysql-migration rollback database-name batch`
148
+ This project is distributed under a **custom non-commercial license**. Please review [`LICENSE.md`](LICENSE.md) for the full terms before using the software.
59
149
 
60
- This will roll back migrations to the given batch number.
150
+ Made with ❤️ by [SherKan](https://github.com/SherKan-n)
61
151
 
62
- > **Copyright (c) 2023-present [𝐒𝐡𝐞𝐫𝐊𝐚𝐧](https://github.com/SherKan-n). All Rights Reserved.**
152
+ </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mysql-migration",
3
- "version": "1.2.3",
3
+ "version": "1.2.4",
4
4
  "description": "Migration for mysql database",
5
5
  "main": "index.js",
6
6
  "bin": {