π FREE Cross-platform database migration and seeding tool with rollback support
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.
- 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
- ποΈ 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
npm install -g database-migration-toolnpm install database-migration-toolgit clone https://github.com/kasbahcode/database-migration-tool.git
cd database-migration-tool
npm install
npm run build# Copy example environment file
cp env.example .env
# Edit .env with your database settings
# Then initialize
dbmigrate initdbmigrate create create_users_tabledbmigrate updbmigrate seed:create initial_users
dbmigrate seed:run| 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 |
Create a .env file in your project root:
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"DB_TYPE=sqlite
DB_FILENAME=./database.sqlite
DATABASE_URL="file:./database.sqlite"DB_TYPE=mongodb
DB_URL=mongodb://localhost:27017
DB_NAME=mydb
DATABASE_URL="mongodb://localhost:27017/mydb"- β MySQL - Full support with connection pooling
- β PostgreSQL - Complete PostgreSQL integration
- β SQLite - File-based database support
- β MongoDB - NoSQL document database support
βββ 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
// 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');
};// 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')
`);
};This is a FREE and open-source project! Contributions are welcome:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- π 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
This project is licensed under the MIT License - see the LICENSE file for details.
- 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