john-migrator


Namejohn-migrator JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://github.com/Krishna-chauhan/john-migrator.git
SummaryA lightweight database migration tool for Python projects
upload_time2025-08-24 21:42:01
maintainerNone
docs_urlNone
authorJohn Doe
requires_python>=3.7
licenseNone
keywords database migration sqlalchemy postgresql mysql
VCS
bugtrack_url
requirements sqlalchemy psycopg2-binary python-dotenv
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ๐Ÿš€ **DB Migrator**

A lightweight database migration tool for managing and automating schema changes effortlessly.

---

## ๐Ÿ“‹ Requirements

- **Python**: 3.7 or higher
- **Database**: PostgreSQL (primary) or MySQL
- **Dependencies**: SQLAlchemy 2.0+, psycopg2-binary, python-dotenv

### ๐Ÿ Python Version Compatibility

| Python Version | Status | Notes |
|----------------|--------|-------|
| 3.7 | โœ… Supported | Minimum required version |
| 3.8 | โœ… Supported | Full compatibility |
| 3.9 | โœ… Supported | Full compatibility |
| 3.10 | โœ… Supported | Full compatibility |
| 3.11 | โœ… Supported | Full compatibility |
| 3.12 | โœ… Supported | Full compatibility |
| 3.6 | โŒ Not Supported | Missing f-string support |

**Note**: Python 3.7+ is required due to the use of f-strings and modern importlib features.

---

## ๐Ÿ“ฆ Features

- โœ… Seamless migration management โ€” apply and rollback with ease
- โœ… Tracks applied migrations using a `schema_migrations` table
- โœ… Supports both **PostgreSQL** and **MySQL**
- โœ… Robust error handling and detailed logging
- โœ… Works in any Python project directory
- โœ… **NEW**: Define table columns when creating migrations

---

## ๐Ÿ› ๏ธ Installation

```bash
pip install john-migrator
```

## ๐Ÿš€ Quick Start

### 1. Initialize Your Project

First, create a default configuration file:

```bash
john-migrator init
```

This creates a `john_migrator_config.py` file in your project root with default settings.

### 2. Configure Your Database

Edit the generated `john_migrator_config.py` file:

```python
# john_migrator_config.py
DB_USER = "your_username"
DB_PASSWORD = "your_password"
DB_HOST = "localhost"
DB_PORT = "5432"
DB_NAME = "your_database"
MIGRATION_FOLDER = "migrations"  # Optional: defaults to ./migrations
```

Or use environment variables:

```bash
export DB_USER=your_username
export DB_PASSWORD=your_password
export DB_HOST=localhost
export DB_PORT=5432
export DB_NAME=your_database
```

### 3. Create Your First Migration

#### Simple Migration (with default columns):
```bash
john-migrator create create_users_table
```

#### Migration with Custom Columns:
```bash
john-migrator create users username:varchar(255) age:integer email:varchar(100) is_active:boolean
```

This creates a migration file in your `migrations/` folder with the specified columns.

### 4. Edit the Migration (if needed)

Open the generated file and customize your SQL:

```python
from john_migrator.migrations.base_migration import BaseMigration

class Users(BaseMigration):
    def __init__(self):
        self.table_name = "users"

    def up(self):
        return """
        CREATE TABLE users (
            id SERIAL PRIMARY KEY,
            username VARCHAR(255),
            age INTEGER,
            email VARCHAR(100),
            is_active BOOLEAN,
            created_at TIMESTAMP DEFAULT NOW(),
            updated_at TIMESTAMP DEFAULT NOW()
        );
        """

    def down(self):
        return 'DROP TABLE IF EXISTS "users";'
```

### 5. Run Migrations

```bash
# Apply all pending migrations
john-migrator up

# Rollback the latest migration
john-migrator down

# Create a new migration with columns
john-migrator create products name:varchar(255) price:decimal(10,2) category:varchar(100)

# Modify existing tables
john-migrator alter users add age:integer add email:varchar(100)
john-migrator alter products drop old_price rename product_name:name
```

---

## ๐Ÿ› ๏ธ Commands

| Command | Description | Example |
|---------|-------------|---------|
| `init` | Create a default configuration file | `john-migrator init` |
| `create` | Create a new migration file | `john-migrator create users name:varchar(255) age:integer` |
| `alter` | Create an ALTER TABLE migration | `john-migrator alter users add age:integer add email:varchar(100)` |
| `up` | Apply pending migrations | `john-migrator up` |
| `down` | Rollback the latest migration | `john-migrator down` |
| `status` | Show migration status | `john-migrator status` |
| `run` | Run a specific migration | `john-migrator run m_20250101120000_create_users up` |

### Command Details

#### `john-migrator init`
Creates a `john_migrator_config.py` file with default database and migration settings. This is the first command you should run in a new project.

#### `john-migrator create <name> [columns...]`
Creates a new migration file with the specified name and optional column definitions.

**Examples:**
```bash
# Simple migration
john-migrator create users

# Migration with columns
john-migrator create products name:varchar(255) price:decimal(10,2) category:varchar(100)
```

#### `john-migrator alter <table> <operations...>`
Creates an ALTER TABLE migration to modify existing tables.

**Operations:**
- `add column_name:type` - Add a new column
- `drop column_name` - Drop an existing column  
- `modify column_name:new_type` - Modify column type
- `rename old_name:new_name` - Rename a column

**Examples:**
```bash
# Add columns
john-migrator alter users add age:integer add email:varchar(100)

# Drop and modify columns
john-migrator alter users drop old_column modify name:varchar(500)

# Rename columns
john-migrator alter products rename product_name:name

# Complex operations
john-migrator alter products add price:decimal(10,2) drop old_price rename product_name:name
```

#### `john-migrator up`
Applies all pending migrations that haven't been run yet.

#### `john-migrator down`
Rolls back the most recent batch of migrations.

#### `john-migrator status`
Shows the status of all migrations (applied vs pending).

#### `john-migrator run <migration> <action>`
Runs a specific migration with the specified action (up or down).

**Examples:**
```bash
john-migrator run m_20250101120000_create_users up
john-migrator run m_20250101120000_create_users down
```

---

## ๐Ÿ—๏ธ Architecture

The DB Migrator is built with a clean, modular architecture:

### Core Classes

- **`MigrationManager`** - Main orchestrator that coordinates all migration operations
- **`DatabaseManager`** - Handles database connections and operations
- **`MigrationGenerator`** - Creates migration files and manages templates
- **`MigrationRunner`** - Executes migrations and handles rollbacks

### File Structure

```
src/
โ”œโ”€โ”€ __init__.py              # Package initialization
โ”œโ”€โ”€ config.py                # Configuration management
โ”œโ”€โ”€ cli.py                   # Command line interface
โ”œโ”€โ”€ migrate.py               # Legacy interface (backward compatibility)
โ”œโ”€โ”€ migration_manager.py     # Main migration orchestrator
โ”œโ”€โ”€ database_manager.py      # Database operations
โ”œโ”€โ”€ migration_generator.py   # Migration file generation
โ”œโ”€โ”€ migration_runner.py      # Migration execution
โ””โ”€โ”€ migrations/
    โ”œโ”€โ”€ __init__.py
    โ”œโ”€โ”€ base_migration.py    # Abstract base class
    โ””โ”€โ”€ *.py                 # Generated migration files
```

### Usage in Code

You can also use the package programmatically:

```python
from john_migrator import MigrationManager

# Initialize the manager
manager = MigrationManager()

# Create a migration
manager.create_migration("users", ["name:varchar(255)", "age:integer"])

# Run migrations
manager.run_migrations()

# Check status
manager.get_status()
```

---

## ๐Ÿ”„ ALTER TABLE Operations

The `alter` command supports various table modification operations:

### Supported Operations

| Operation | Syntax | Description | Rollback |
|-----------|--------|-------------|----------|
| **Add Column** | `add column_name:type` | Adds a new column to the table | โœ… Automatic (drops column) |
| **Drop Column** | `drop column_name` | Removes a column from the table | โš ๏ธ Manual (requires original type) |
| **Modify Column** | `modify column_name:new_type` | Changes column data type | โš ๏ธ Manual (requires original type) |
| **Rename Column** | `rename old_name:new_name` | Renames a column | โœ… Automatic (renames back) |

### Rollback Behavior

- **โœ… Automatic Rollback**: Operations that can be automatically reversed
- **โš ๏ธ Manual Rollback**: Operations that require manual intervention

**Example Migration:**
```python
def up(self):
    return """
    ALTER TABLE users ADD COLUMN age INTEGER;
    ALTER TABLE users DROP COLUMN old_column;
    ALTER TABLE users RENAME COLUMN product_name TO name;
    """

def down(self):
    return """
    ALTER TABLE users DROP COLUMN age;
    -- ALTER TABLE users ADD COLUMN old_column <original_type>; -- Manual rollback required
    ALTER TABLE users RENAME COLUMN name TO product_name;
    """
```

### Best Practices

1. **Test rollbacks** before applying to production
2. **Document manual rollbacks** for complex operations
3. **Use transactions** for multiple operations
4. **Backup data** before destructive operations

---

## ๐Ÿ“ Column Definition Syntax

When creating migrations, you can specify columns using the format: `column_name:data_type`

### Examples:
```bash
# Basic types
john-migrator create users name:varchar(255) age:integer

# With constraints
john-migrator create posts title:varchar(255) content:text author_id:integer

# Boolean and other types
john-migrator create settings user_id:integer is_active:boolean created_at:timestamp
```

### Supported Data Types:
- `varchar(n)` - Variable length string
- `text` - Long text
- `integer` - Integer number
- `bigint` - Large integer
- `decimal(p,s)` - Decimal number with precision
- `boolean` - True/False
- `timestamp` - Date and time
- `date` - Date only
- `json` - JSON data
- `uuid` - UUID/GUID

### Default Behavior:
- If no columns are specified, a default `name VARCHAR(255)` column is added
- If a column is specified without a type (e.g., `name`), it defaults to `VARCHAR(255)`
- All tables automatically get `id SERIAL PRIMARY KEY`, `created_at`, and `updated_at` columns

---

## ๐Ÿ“ Project Structure

After installation, your project structure will look like:

```
your-project/
โ”œโ”€โ”€ john_migrator_config.py    # Database configuration
โ”œโ”€โ”€ migrations/                # Your migration files
โ”‚   โ”œโ”€โ”€ m_20250101120000_create_users_table.py
โ”‚   โ””โ”€โ”€ m_20250101120001_add_user_profile.py
โ””โ”€โ”€ .env                       # Optional: environment variables
```

---

## ๐Ÿ”ง Configuration Options

| Option | Environment Variable | Default | Description |
|--------|---------------------|---------|-------------|
| `DB_USER` | `DB_USER` | `default_user` | Database username |
| `DB_PASSWORD` | `DB_PASSWORD` | `default_password` | Database password |
| `DB_HOST` | `DB_HOST` | `localhost` | Database host |
| `DB_PORT` | `DB_PORT` | `5432` | Database port |
| `DB_NAME` | `DB_NAME` | `default_db` | Database name |
| `MIGRATION_FOLDER` | `MIGRATION_FOLDER` | `./migrations` | Migration files location |
| `MIGRATION_TABLE` | `MIGRATION_TABLE` | `migrations` | Migration tracking table |

---

## ๐Ÿงช Development

### Testing Different Python Versions

To test compatibility with different Python versions, you can use:

```bash
# Using pyenv (recommended)
pyenv install 3.7.17
pyenv install 3.8.18
pyenv install 3.9.18
pyenv install 3.10.13
pyenv install 3.11.7
pyenv install 3.12.1

# Test each version
pyenv local 3.7.17 && python -m pip install -e .
pyenv local 3.8.18 && python -m pip install -e .
pyenv local 3.9.18 && python -m pip install -e .
pyenv local 3.10.13 && python -m pip install -e .
pyenv local 3.11.7 && python -m pip install -e .
pyenv local 3.12.1 && python -m pip install -e .
```

### Using Docker for Testing

```dockerfile
# Dockerfile for testing multiple Python versions
FROM python:3.7-slim
WORKDIR /app
COPY . .
RUN pip install -e .
CMD ["john-migrator", "--help"]
```

---

## ๐Ÿ“ Migration Best Practices

1. **Always test migrations** in a development environment first
2. **Keep migrations small** and focused on a single change
3. **Use descriptive names** for your migration files
4. **Always implement both `up()` and `down()` methods**
5. **Use transactions** for complex migrations (handled automatically)
6. **Define columns when creating** to save time and reduce errors

---

Stay in control of your database schema with **DB Migrator**! โœจ


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Krishna-chauhan/john-migrator.git",
    "name": "john-migrator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "database migration sqlalchemy postgresql mysql",
    "author": "John Doe",
    "author_email": "krishnachauhan20993@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/97/5f/7879e5c156048ff563bbf5c81ca562026e15a70d0df2fde10c01efda1405/john_migrator-1.2.0.tar.gz",
    "platform": null,
    "description": "# \ud83d\ude80 **DB Migrator**\n\nA lightweight database migration tool for managing and automating schema changes effortlessly.\n\n---\n\n## \ud83d\udccb Requirements\n\n- **Python**: 3.7 or higher\n- **Database**: PostgreSQL (primary) or MySQL\n- **Dependencies**: SQLAlchemy 2.0+, psycopg2-binary, python-dotenv\n\n### \ud83d\udc0d Python Version Compatibility\n\n| Python Version | Status | Notes |\n|----------------|--------|-------|\n| 3.7 | \u2705 Supported | Minimum required version |\n| 3.8 | \u2705 Supported | Full compatibility |\n| 3.9 | \u2705 Supported | Full compatibility |\n| 3.10 | \u2705 Supported | Full compatibility |\n| 3.11 | \u2705 Supported | Full compatibility |\n| 3.12 | \u2705 Supported | Full compatibility |\n| 3.6 | \u274c Not Supported | Missing f-string support |\n\n**Note**: Python 3.7+ is required due to the use of f-strings and modern importlib features.\n\n---\n\n## \ud83d\udce6 Features\n\n- \u2705 Seamless migration management \u2014 apply and rollback with ease\n- \u2705 Tracks applied migrations using a `schema_migrations` table\n- \u2705 Supports both **PostgreSQL** and **MySQL**\n- \u2705 Robust error handling and detailed logging\n- \u2705 Works in any Python project directory\n- \u2705 **NEW**: Define table columns when creating migrations\n\n---\n\n## \ud83d\udee0\ufe0f Installation\n\n```bash\npip install john-migrator\n```\n\n## \ud83d\ude80 Quick Start\n\n### 1. Initialize Your Project\n\nFirst, create a default configuration file:\n\n```bash\njohn-migrator init\n```\n\nThis creates a `john_migrator_config.py` file in your project root with default settings.\n\n### 2. Configure Your Database\n\nEdit the generated `john_migrator_config.py` file:\n\n```python\n# john_migrator_config.py\nDB_USER = \"your_username\"\nDB_PASSWORD = \"your_password\"\nDB_HOST = \"localhost\"\nDB_PORT = \"5432\"\nDB_NAME = \"your_database\"\nMIGRATION_FOLDER = \"migrations\"  # Optional: defaults to ./migrations\n```\n\nOr use environment variables:\n\n```bash\nexport DB_USER=your_username\nexport DB_PASSWORD=your_password\nexport DB_HOST=localhost\nexport DB_PORT=5432\nexport DB_NAME=your_database\n```\n\n### 3. Create Your First Migration\n\n#### Simple Migration (with default columns):\n```bash\njohn-migrator create create_users_table\n```\n\n#### Migration with Custom Columns:\n```bash\njohn-migrator create users username:varchar(255) age:integer email:varchar(100) is_active:boolean\n```\n\nThis creates a migration file in your `migrations/` folder with the specified columns.\n\n### 4. Edit the Migration (if needed)\n\nOpen the generated file and customize your SQL:\n\n```python\nfrom john_migrator.migrations.base_migration import BaseMigration\n\nclass Users(BaseMigration):\n    def __init__(self):\n        self.table_name = \"users\"\n\n    def up(self):\n        return \"\"\"\n        CREATE TABLE users (\n            id SERIAL PRIMARY KEY,\n            username VARCHAR(255),\n            age INTEGER,\n            email VARCHAR(100),\n            is_active BOOLEAN,\n            created_at TIMESTAMP DEFAULT NOW(),\n            updated_at TIMESTAMP DEFAULT NOW()\n        );\n        \"\"\"\n\n    def down(self):\n        return 'DROP TABLE IF EXISTS \"users\";'\n```\n\n### 5. Run Migrations\n\n```bash\n# Apply all pending migrations\njohn-migrator up\n\n# Rollback the latest migration\njohn-migrator down\n\n# Create a new migration with columns\njohn-migrator create products name:varchar(255) price:decimal(10,2) category:varchar(100)\n\n# Modify existing tables\njohn-migrator alter users add age:integer add email:varchar(100)\njohn-migrator alter products drop old_price rename product_name:name\n```\n\n---\n\n## \ud83d\udee0\ufe0f Commands\n\n| Command | Description | Example |\n|---------|-------------|---------|\n| `init` | Create a default configuration file | `john-migrator init` |\n| `create` | Create a new migration file | `john-migrator create users name:varchar(255) age:integer` |\n| `alter` | Create an ALTER TABLE migration | `john-migrator alter users add age:integer add email:varchar(100)` |\n| `up` | Apply pending migrations | `john-migrator up` |\n| `down` | Rollback the latest migration | `john-migrator down` |\n| `status` | Show migration status | `john-migrator status` |\n| `run` | Run a specific migration | `john-migrator run m_20250101120000_create_users up` |\n\n### Command Details\n\n#### `john-migrator init`\nCreates a `john_migrator_config.py` file with default database and migration settings. This is the first command you should run in a new project.\n\n#### `john-migrator create <name> [columns...]`\nCreates a new migration file with the specified name and optional column definitions.\n\n**Examples:**\n```bash\n# Simple migration\njohn-migrator create users\n\n# Migration with columns\njohn-migrator create products name:varchar(255) price:decimal(10,2) category:varchar(100)\n```\n\n#### `john-migrator alter <table> <operations...>`\nCreates an ALTER TABLE migration to modify existing tables.\n\n**Operations:**\n- `add column_name:type` - Add a new column\n- `drop column_name` - Drop an existing column  \n- `modify column_name:new_type` - Modify column type\n- `rename old_name:new_name` - Rename a column\n\n**Examples:**\n```bash\n# Add columns\njohn-migrator alter users add age:integer add email:varchar(100)\n\n# Drop and modify columns\njohn-migrator alter users drop old_column modify name:varchar(500)\n\n# Rename columns\njohn-migrator alter products rename product_name:name\n\n# Complex operations\njohn-migrator alter products add price:decimal(10,2) drop old_price rename product_name:name\n```\n\n#### `john-migrator up`\nApplies all pending migrations that haven't been run yet.\n\n#### `john-migrator down`\nRolls back the most recent batch of migrations.\n\n#### `john-migrator status`\nShows the status of all migrations (applied vs pending).\n\n#### `john-migrator run <migration> <action>`\nRuns a specific migration with the specified action (up or down).\n\n**Examples:**\n```bash\njohn-migrator run m_20250101120000_create_users up\njohn-migrator run m_20250101120000_create_users down\n```\n\n---\n\n## \ud83c\udfd7\ufe0f Architecture\n\nThe DB Migrator is built with a clean, modular architecture:\n\n### Core Classes\n\n- **`MigrationManager`** - Main orchestrator that coordinates all migration operations\n- **`DatabaseManager`** - Handles database connections and operations\n- **`MigrationGenerator`** - Creates migration files and manages templates\n- **`MigrationRunner`** - Executes migrations and handles rollbacks\n\n### File Structure\n\n```\nsrc/\n\u251c\u2500\u2500 __init__.py              # Package initialization\n\u251c\u2500\u2500 config.py                # Configuration management\n\u251c\u2500\u2500 cli.py                   # Command line interface\n\u251c\u2500\u2500 migrate.py               # Legacy interface (backward compatibility)\n\u251c\u2500\u2500 migration_manager.py     # Main migration orchestrator\n\u251c\u2500\u2500 database_manager.py      # Database operations\n\u251c\u2500\u2500 migration_generator.py   # Migration file generation\n\u251c\u2500\u2500 migration_runner.py      # Migration execution\n\u2514\u2500\u2500 migrations/\n    \u251c\u2500\u2500 __init__.py\n    \u251c\u2500\u2500 base_migration.py    # Abstract base class\n    \u2514\u2500\u2500 *.py                 # Generated migration files\n```\n\n### Usage in Code\n\nYou can also use the package programmatically:\n\n```python\nfrom john_migrator import MigrationManager\n\n# Initialize the manager\nmanager = MigrationManager()\n\n# Create a migration\nmanager.create_migration(\"users\", [\"name:varchar(255)\", \"age:integer\"])\n\n# Run migrations\nmanager.run_migrations()\n\n# Check status\nmanager.get_status()\n```\n\n---\n\n## \ud83d\udd04 ALTER TABLE Operations\n\nThe `alter` command supports various table modification operations:\n\n### Supported Operations\n\n| Operation | Syntax | Description | Rollback |\n|-----------|--------|-------------|----------|\n| **Add Column** | `add column_name:type` | Adds a new column to the table | \u2705 Automatic (drops column) |\n| **Drop Column** | `drop column_name` | Removes a column from the table | \u26a0\ufe0f Manual (requires original type) |\n| **Modify Column** | `modify column_name:new_type` | Changes column data type | \u26a0\ufe0f Manual (requires original type) |\n| **Rename Column** | `rename old_name:new_name` | Renames a column | \u2705 Automatic (renames back) |\n\n### Rollback Behavior\n\n- **\u2705 Automatic Rollback**: Operations that can be automatically reversed\n- **\u26a0\ufe0f Manual Rollback**: Operations that require manual intervention\n\n**Example Migration:**\n```python\ndef up(self):\n    return \"\"\"\n    ALTER TABLE users ADD COLUMN age INTEGER;\n    ALTER TABLE users DROP COLUMN old_column;\n    ALTER TABLE users RENAME COLUMN product_name TO name;\n    \"\"\"\n\ndef down(self):\n    return \"\"\"\n    ALTER TABLE users DROP COLUMN age;\n    -- ALTER TABLE users ADD COLUMN old_column <original_type>; -- Manual rollback required\n    ALTER TABLE users RENAME COLUMN name TO product_name;\n    \"\"\"\n```\n\n### Best Practices\n\n1. **Test rollbacks** before applying to production\n2. **Document manual rollbacks** for complex operations\n3. **Use transactions** for multiple operations\n4. **Backup data** before destructive operations\n\n---\n\n## \ud83d\udcdd Column Definition Syntax\n\nWhen creating migrations, you can specify columns using the format: `column_name:data_type`\n\n### Examples:\n```bash\n# Basic types\njohn-migrator create users name:varchar(255) age:integer\n\n# With constraints\njohn-migrator create posts title:varchar(255) content:text author_id:integer\n\n# Boolean and other types\njohn-migrator create settings user_id:integer is_active:boolean created_at:timestamp\n```\n\n### Supported Data Types:\n- `varchar(n)` - Variable length string\n- `text` - Long text\n- `integer` - Integer number\n- `bigint` - Large integer\n- `decimal(p,s)` - Decimal number with precision\n- `boolean` - True/False\n- `timestamp` - Date and time\n- `date` - Date only\n- `json` - JSON data\n- `uuid` - UUID/GUID\n\n### Default Behavior:\n- If no columns are specified, a default `name VARCHAR(255)` column is added\n- If a column is specified without a type (e.g., `name`), it defaults to `VARCHAR(255)`\n- All tables automatically get `id SERIAL PRIMARY KEY`, `created_at`, and `updated_at` columns\n\n---\n\n## \ud83d\udcc1 Project Structure\n\nAfter installation, your project structure will look like:\n\n```\nyour-project/\n\u251c\u2500\u2500 john_migrator_config.py    # Database configuration\n\u251c\u2500\u2500 migrations/                # Your migration files\n\u2502   \u251c\u2500\u2500 m_20250101120000_create_users_table.py\n\u2502   \u2514\u2500\u2500 m_20250101120001_add_user_profile.py\n\u2514\u2500\u2500 .env                       # Optional: environment variables\n```\n\n---\n\n## \ud83d\udd27 Configuration Options\n\n| Option | Environment Variable | Default | Description |\n|--------|---------------------|---------|-------------|\n| `DB_USER` | `DB_USER` | `default_user` | Database username |\n| `DB_PASSWORD` | `DB_PASSWORD` | `default_password` | Database password |\n| `DB_HOST` | `DB_HOST` | `localhost` | Database host |\n| `DB_PORT` | `DB_PORT` | `5432` | Database port |\n| `DB_NAME` | `DB_NAME` | `default_db` | Database name |\n| `MIGRATION_FOLDER` | `MIGRATION_FOLDER` | `./migrations` | Migration files location |\n| `MIGRATION_TABLE` | `MIGRATION_TABLE` | `migrations` | Migration tracking table |\n\n---\n\n## \ud83e\uddea Development\n\n### Testing Different Python Versions\n\nTo test compatibility with different Python versions, you can use:\n\n```bash\n# Using pyenv (recommended)\npyenv install 3.7.17\npyenv install 3.8.18\npyenv install 3.9.18\npyenv install 3.10.13\npyenv install 3.11.7\npyenv install 3.12.1\n\n# Test each version\npyenv local 3.7.17 && python -m pip install -e .\npyenv local 3.8.18 && python -m pip install -e .\npyenv local 3.9.18 && python -m pip install -e .\npyenv local 3.10.13 && python -m pip install -e .\npyenv local 3.11.7 && python -m pip install -e .\npyenv local 3.12.1 && python -m pip install -e .\n```\n\n### Using Docker for Testing\n\n```dockerfile\n# Dockerfile for testing multiple Python versions\nFROM python:3.7-slim\nWORKDIR /app\nCOPY . .\nRUN pip install -e .\nCMD [\"john-migrator\", \"--help\"]\n```\n\n---\n\n## \ud83d\udcdd Migration Best Practices\n\n1. **Always test migrations** in a development environment first\n2. **Keep migrations small** and focused on a single change\n3. **Use descriptive names** for your migration files\n4. **Always implement both `up()` and `down()` methods**\n5. **Use transactions** for complex migrations (handled automatically)\n6. **Define columns when creating** to save time and reduce errors\n\n---\n\nStay in control of your database schema with **DB Migrator**! \u2728\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A lightweight database migration tool for Python projects",
    "version": "1.2.0",
    "project_urls": {
        "Bug Reports": "https://github.com/Krishna-chauhan/john-migrator/issues",
        "Homepage": "https://github.com/Krishna-chauhan/john-migrator.git",
        "Source": "https://github.com/Krishna-chauhan/john-migrator"
    },
    "split_keywords": [
        "database",
        "migration",
        "sqlalchemy",
        "postgresql",
        "mysql"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "05106faa03b617d6143e2f53ad68dd0179462cd21a10b5cd60ec86361029499b",
                "md5": "efe0dab8f503ab38f1a44a42c8202610",
                "sha256": "70fa0e9c187dd0bc8a2db6838f9dd84956a5c977b39abae6d90d3a566ab1ba44"
            },
            "downloads": -1,
            "filename": "john_migrator-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "efe0dab8f503ab38f1a44a42c8202610",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 18065,
            "upload_time": "2025-08-24T21:42:00",
            "upload_time_iso_8601": "2025-08-24T21:42:00.040955Z",
            "url": "https://files.pythonhosted.org/packages/05/10/6faa03b617d6143e2f53ad68dd0179462cd21a10b5cd60ec86361029499b/john_migrator-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "975f7879e5c156048ff563bbf5c81ca562026e15a70d0df2fde10c01efda1405",
                "md5": "b66b40fe57be181b1b04ca80fb3e26c0",
                "sha256": "7d87f62f9d4eb73c4d838be432733fd41c36d07e8589e4f8d6ce0681e0d4108e"
            },
            "downloads": -1,
            "filename": "john_migrator-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b66b40fe57be181b1b04ca80fb3e26c0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 33322,
            "upload_time": "2025-08-24T21:42:01",
            "upload_time_iso_8601": "2025-08-24T21:42:01.791011Z",
            "url": "https://files.pythonhosted.org/packages/97/5f/7879e5c156048ff563bbf5c81ca562026e15a70d0df2fde10c01efda1405/john_migrator-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-24 21:42:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Krishna-chauhan",
    "github_project": "john-migrator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "sqlalchemy",
            "specs": [
                [
                    ">=",
                    "2.0.0"
                ]
            ]
        },
        {
            "name": "psycopg2-binary",
            "specs": [
                [
                    ">=",
                    "2.9.0"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ]
            ]
        }
    ],
    "lcname": "john-migrator"
}
        
Elapsed time: 0.90424s