Package Exports
- db-migrate-cli
- db-migrate-cli/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (db-migrate-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
db-migrate-cli
db-migrate-cli is a command-line interface tool designed for managing database migrations with MySQL and MariaDB. It simplifies the process of creating, applying, and rolling back database changes.
Table of Contents
Installation
To install the tool globally, use npm:
npm install -g db-migrate-cliThis will make the db-cli command available globally on your system, allowing you to run migration commands from anywhere.
Usage
Commands
setup
Initializes the migration configuration by creating the config/migration.js file in the current working directory. Configure the migrationDir and database settings in this file after running the command.
db-cli setupmigrate:init
Sets up the migration infrastructure by creating the db_migrations table in your configured database and establishing the necessary stored procedures.
db-cli migrate:initmake:migration
Generates a new migration file within the migrationDir specified in config/migration.js. The file name includes a timestamp and the provided name, converted to snake case.
db-cli make:migration <migration_name>migrate
Executes all pending migrations, applying them to the configured database.
db-cli migraterollback
Reverts the most recent batch of migrations, undoing the last changes applied.
db-cli rollbackConfiguration
After running db-cli setup, edit the config/migration.js file to specify:
migrationDir: Directory where migration files are stored.- Database connection settings: Configure your database connection parameters.
Dependencies
chalk: Used for styling terminal output.commander: Command-line argument parser.fs.promises: Promises API for interacting with the filesystem.mysql2: MySQL client for Node.js.path: Utility for handling and transforming file paths.
License
This project is licensed under the MIT License.
Author
Developed by Anjutech (arunkumar@anjutech.com).