Skip to content

kasbahcode/database-migration-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Database Migration Tool

πŸ”„ FREE Cross-platform database migration and seeding tool with rollback support

License: MIT Node.js TypeScript

🌟 Overview

A powerful, free, and open-source database migration tool that supports multiple database systems with rollback capabilities, seeding functionality, and version control for your database schema changes.

πŸ› οΈ Technologies

  • Node.js - Runtime environment
  • TypeScript - Type-safe development
  • SQL - MySQL, PostgreSQL, SQLite support
  • MongoDB - NoSQL database support
  • CLI - Command-line interface
  • Prisma - Database toolkit integration

✨ Key Features

  • πŸ—„οΈ Multi-DB Support - MySQL, PostgreSQL, SQLite, MongoDB
  • βͺ Rollback Support - Safely rollback migrations with confirmation
  • 🌱 Seed Data - Populate databases with initial/test data
  • πŸ“ Version Control - Track migration history and status
  • πŸ–₯️ CLI Interface - Easy-to-use command line interface
  • πŸ”§ Prisma Integration - Works seamlessly with Prisma ORM
  • πŸ†“ Completely FREE - No hidden costs or premium features

πŸš€ Installation

Global Installation

npm install -g database-migration-tool

Local Installation

npm install database-migration-tool

Development Setup

git clone https://github.com/kasbahcode/database-migration-tool.git
cd database-migration-tool
npm install
npm run build

πŸ“– Quick Start

1. Initialize Environment

# Copy example environment file
cp env.example .env

# Edit .env with your database settings
# Then initialize
dbmigrate init

2. Create Your First Migration

dbmigrate create create_users_table

3. Run Migrations

dbmigrate up

4. Create and Run Seeds

dbmigrate seed:create initial_users
dbmigrate seed:run

πŸ“‹ Available Commands

Command Description
dbmigrate init Initialize migration environment
dbmigrate create <name> Create a new migration
dbmigrate up Run pending migrations
dbmigrate down [--steps <n>] Rollback migrations
dbmigrate status Show migration status
dbmigrate seed:create <name> Create a new seed
dbmigrate seed:run [--name <name>] Run seeds
dbmigrate seed:status Show seed status
dbmigrate config Show database configuration
npm run df3 Generate Prisma files and migrate

βš™οΈ Configuration

Create a .env file in your project root:

MySQL/PostgreSQL

DB_TYPE=mysql
DB_HOST=localhost
DB_PORT=3306
DB_USER=root
DB_PASSWORD=password
DB_NAME=mydb
DATABASE_URL="mysql://root:password@localhost:3306/mydb"

SQLite

DB_TYPE=sqlite
DB_FILENAME=./database.sqlite
DATABASE_URL="file:./database.sqlite"

MongoDB

DB_TYPE=mongodb
DB_URL=mongodb://localhost:27017
DB_NAME=mydb
DATABASE_URL="mongodb://localhost:27017/mydb"

πŸ—ƒοΈ Supported Databases

  • βœ… MySQL - Full support with connection pooling
  • βœ… PostgreSQL - Complete PostgreSQL integration
  • βœ… SQLite - File-based database support
  • βœ… MongoDB - NoSQL document database support

πŸ“ Project Structure

β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ adapters/     # Database-specific implementations
β”‚   β”œβ”€β”€ services/     # Business logic
β”‚   β”œβ”€β”€ config/       # Configuration management
β”‚   β”œβ”€β”€ types/        # TypeScript interfaces
β”‚   └── cli.ts        # CLI interface
β”œβ”€β”€ migrations/       # Your migration files
β”œβ”€β”€ seeds/           # Your seed files
└── prisma/          # Prisma schema and migrations

πŸ”„ Migration Example

// migrations/2024-01-01_create_users.js
exports.up = async (db) => {
  await db.run(`
    CREATE TABLE users (
      id INTEGER PRIMARY KEY AUTOINCREMENT,
      email TEXT UNIQUE NOT NULL,
      name TEXT NOT NULL,
      created_at DATETIME DEFAULT CURRENT_TIMESTAMP
    )
  `);
};

exports.down = async (db) => {
  await db.run('DROP TABLE users');
};

🌱 Seed Example

// seeds/2024-01-01_initial_users.js
exports.seed = async (db) => {
  await db.run(`
    INSERT INTO users (email, name) VALUES 
    ('admin@example.com', 'Admin User'),
    ('user@example.com', 'Regular User')
  `);
};

🀝 Contributing

This is a FREE and open-source project! Contributions are welcome:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“Š Why Choose This Tool?

  • πŸ†“ 100% Free - No licensing fees, ever
  • πŸ”“ Open Source - Full transparency and community driven
  • πŸš€ Production Ready - Battle-tested and reliable
  • πŸ“š Well Documented - Comprehensive guides and examples
  • πŸ›‘οΈ Type Safe - Built with TypeScript for reliability
  • πŸ”§ Extensible - Easy to customize and extend

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with ❀️ for the developer community
  • Inspired by database migration tools across different ecosystems
  • Contributions and feedback from the open-source community

Made with πŸ’š by developers, for developers. Forever FREE! # database-migration-tool

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published