@ky210299/ez-migrate v0.2.0
@ky210299/ez-migrate
A lightweight CLI for database migrations and SQL seedsโdesigned for simplicity, speed, and reliability.
Perfect for small-to-medium projects that need an easy, zero-boilerplate way to version your schema and seed data.
๐ Table of Contents
๐ Installation
# Global install (recommended)
npm install -g @ky210299/ez-migrate
# Local install
npm install @ky210299/ez-migrateRun via:
# If installed globally:
ez-migrate <command> [options]
# If installed locally:
npx @ky210299/ez-migrate <command> [options]๐ง Usage
Initialize a minimal config file in your project root:
ez-migrate init [path]โ๏ธ Configuration
When you run ez-migrate init, it will generate an ez-migrate.config.json file (and create the migrations/seeds folders if missing).
ez-migrate.config.json
This file defines how database migrations and seeds are managed and executed.
๐น dialect
The database type where migrations will be applied.
Possible values: "mysql", "sqlite" (others may be added in the future).
๐น migrationsPath
Path to the directory where SQL migration files are stored.
Example: "./migrations"
๐น seedsPath
Path to the directory where SQL seed files are stored.
Example: "./seeds"
๐ธ envKeys
Specifies the environment variable names used to connect to the main database.
{
"user": "DB_USER", // Database user
"password": "DB_PASSWORD", // Database password
"port": "DB_PORT", // Database port
"host": "DB_HOST", // Database host
"database": "DB_NAME" // Database name
}๐ธ tracker
Configuration for the tracker database, used to record which migrations have been applied.
{
"envKeys": {
"user": "DB_USER",
"password": "DB_PASSWORD",
"port": "DB_PORT",
"host": "DB_HOST",
"database": "DB_NAME"
},
"dialect": "mysql", // or "sqlite"
"sqlitePath": "./migrations" // only for sqlite tracker
}๐ Commands
ez-migrate <command> [options]make
Create a new migration file inmigrations/.-s, --seed: create a seed file inseeds/instead.
seed
Execute all SQL seed files in order.init path
Generate config filestatus
Display applied vs pending migrations.migrate
Apply all pending migrations.up
Run the next pending migration.down
Roll back the most recent migration.rollback
Revert the last batch of migrations done.reset
Roll back and apply all migrationsredo
Undo and reapply the last migration.
๐ก Examples
# Create a new migration
ez-migrate make add_users_table
# Create a new seed
ez-migrate make --seed populate_demo_data
# Apply pending migrations
ez-migrate migrate
# Roll back last batch
ez-migrate rollback
# Check current status
ez-migrate status๐ Environment Variables
Make sure you have set your environment variables and are specified in your ez-migrate.json before running any commands.
You can use a .env
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=secret
DB_PORT=3306
DB_NAME=my_database๐ค Contributing
- Fork the repo
- Create a feature branch (
git switch -c feat/my-feature) - Commit your changes (
git commit -m '{feat|fix|ref|chore}: Add this ..') - Push to the branch (
git push origin feat/my-feature) - Open a Pull Request