Skip to main content

A professional database migration tool supporting multiple databases

Project description

evolvishub-db-migration

Eviesales Database Migration Tool

PyPI version Python Version License Documentation Build Status Code Style Coverage Status

Eviesales Logo

Overview

The Eviesales Database Migration Tool is a robust and flexible solution for managing database schema changes across multiple database systems. It provides a comprehensive set of features for database version control, migration management, and rollback capabilities.

Quick Start

Command-Line Usage

# List available migrations
db-migrate --list

# Show migration status
db-migrate --status

# Apply pending migrations
db-migrate --apply

# Apply migrations with verbose output
db-migrate --apply -v

Key Features

  • Multi-Database Support

    • SQLite
    • PostgreSQL
    • MySQL
    • Microsoft SQL Server
  • Advanced Migration Management

    • Transaction-based migrations
    • Rollback support
    • Migration tracking
    • Version control
  • Professional Features

    • Configurable logging
    • Transaction timeout control
    • Retry mechanisms
    • Schema management
    • Character set support
  • Development Tools

    • Command-line interface
    • Python library API
    • SQLAlchemy integration
    • Testing utilities
    • Documentation support

Features

  • 🚀 Multiple Database Support:
    • SQLite (default)
    • PostgreSQL
    • MySQL
    • Microsoft SQL Server (MSSQL)
  • 🔄 Version Control:
    • Migration naming convention (vX_description.sql)
    • Automatic tracking of applied migrations
    • Rollback support
  • 📝 Flexible Configuration:
    • File-based SQL migrations
    • Inline SQL migrations in config
    • Custom migration directory support
  • 🛠️ Advanced Features:
    • Transaction support
    • Error handling and rollback
    • Migration status tracking
  • 📱 Command-line Interface:
    • List migrations
    • Apply migrations
    • Status checking

Installation

From PyPI

Install the latest release:

pip install evolvishub-db-migration

From Source

For development or specific versions:

# Clone the repository
git clone https://github.com/evolvisai/evolvishub-db-migration.git
cd evolvishub-db-migration

# Install in development mode
pip install -e .

# Or install specific version
pip install git+https://github.com/evolvisai/evolvishub-db-migration.git@v0.1.0

Development

Testing

The project includes comprehensive test coverage:

# Run all tests
pytest

# Run with coverage
pytest --cov=evolvishub_db_migration

# Run specific test file
pytest tests/unit/test_migration_manager.py

Code Style

The code follows the Black code style:

# Format code
black src/ tests/

# Check code style
black --check src/ tests/

Documentation

Generate documentation using Sphinx:

# Build documentation
sphinx-build -b html docs/ docs/_build/

# View documentation
open docs/_build/html/index.html

Contributing

Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

License

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

Support

For support, please:

  1. Check the documentation
  2. Search existing issues
  3. Create a new issue if needed

Acknowledgments

  • SQLAlchemy for database abstraction
  • Alembic for migration inspiration
  • All contributors and users

Configuration

Configure the tool using a migration.ini file in your project root:

[DEFAULT]
# Database Configuration
database_type = sqlite  # sqlite, postgresql, mysql, mssql
connection_string = sqlite:///./database.db
migration_directory = migrations

# Optional Settings
transaction_timeout = 30  # seconds
retry_attempts = 3
log_level = INFO  # DEBUG, INFO, WARNING, ERROR

[MIGRATIONS]
# Inline SQL migrations
v1_create_users_table = CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL);

# Rollback SQL (optional)
rollback_v1_create_users_table = DROP TABLE users;

Migration Files

Create SQL files in your migrations directory following the naming convention: vX_description.sql

-- migrations/v2_add_profiles_table.sql
-- Description: Add profiles table with user reference
CREATE TABLE profiles (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    user_id INTEGER NOT NULL,
    bio TEXT,
    FOREIGN KEY (user_id) REFERENCES users(id)
);

-- rollback.sql
DROP TABLE profiles;

Running Migrations

List available migrations:

db-migrate --list

Apply pending migrations:

db-migrate --apply

Check migration status:

db-migrate --status

Migration Best Practices

  1. Use descriptive version numbers (v1_, v2_, v3_, etc.)
  2. Keep migrations atomic and focused
  3. Include rollback SQL in comments
  4. Use proper SQL formatting
  5. Document complex migrations

Database Support

SQLite

[DEFAULT]
database_type = sqlite
connection_string = sqlite:///./database.db

PostgreSQL

[DEFAULT]
database_type = postgresql
connection_string = postgresql://user:password@localhost:5432/dbname

MySQL

[DEFAULT]
database_type = mysql
connection_string = mysql://user:password@localhost:3306/dbname

MSSQL

[DEFAULT]
database_type = mssql
connection_string = mssql://user:password@localhost:1433/dbname

Development

  1. Clone the repository
  2. Create a virtual environment
  3. Install dependencies
  4. Run tests
  5. Submit a PR

Contributing

Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.

License

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

Acknowledgments

  • Thanks to all contributors
  • Inspired by database migration tools like Alembic and Flyway
  • Special thanks to the SQLAlchemy team for their excellent database toolkit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

evolvishub_db_migration-0.1.0.tar.gz (273.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

evolvishub_db_migration-0.1.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file evolvishub_db_migration-0.1.0.tar.gz.

File metadata

  • Download URL: evolvishub_db_migration-0.1.0.tar.gz
  • Upload date:
  • Size: 273.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.9

File hashes

Hashes for evolvishub_db_migration-0.1.0.tar.gz
Algorithm Hash digest
SHA256 93a7f65d2a577b67a0475863c998942f2777273293768975a78ff8a8882e2614
MD5 1bef74de289f897270cfd28b0298fd1c
BLAKE2b-256 2fed2b6e0a4c9fb7647e3c4e0ae54345230745327156c0eee47ff4f2a781b488

See more details on using hashes here.

File details

Details for the file evolvishub_db_migration-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for evolvishub_db_migration-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7bebb6310695a8990010275ffe909e9ee2f9f37038679a79651c52b18be87d1
MD5 adb7d85f1c7e14b0102f3586cf87968b
BLAKE2b-256 7a84abdc50099396561ea45c0237a94d4a0c6d432a72380209b0b3d7dca7bedf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page