Metadata-Version: 2.4
Name: django-migrate-fresh
Version: 3.1.0
Summary: Simple Django package for Laravel-style migrate:fresh functionality with backup support
Home-page: https://github.com/sepehr-mohseni/django-migrate-fresh
Author: Sepehr Mohseni
Author-email: Sepehr Mohseni <isepehrmohseni@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/sepehr-mohseni/django-migrate-fresh
Project-URL: Repository, https://github.com/sepehr-mohseni/django-migrate-fresh
Project-URL: Issues, https://github.com/sepehr-mohseni/django-migrate-fresh/issues
Keywords: django,migration,laravel,migrate,fresh,backup
Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 4.1
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=3.2
Provides-Extra: test
Requires-Dist: pytest>=6.0; extra == "test"
Requires-Dist: pytest-django>=4.0; extra == "test"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# Django Migrate Fresh 🚀

A simple Django package that provides Laravel-style `migrate:fresh` functionality - drop all tables and re-run migrations with optional backup support.

## Installation

```bash
pip install django-migrate-fresh
```

Add to your `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
    # ... your other apps
    'django_migrate_fresh',
]
```

## Usage

### Basic Usage

Drop all tables and re-run migrations:

```bash
python manage.py migrate_fresh
```

### With Backup

Create a backup before running:

```bash
python manage.py migrate_fresh --backup
```

Specify backup path:

```bash
python manage.py migrate_fresh --backup --backup-path my_backup.sql
```

### Force Mode (No Confirmations)

Skip all confirmations:

```bash
python manage.py migrate_fresh --force
```

## Command Options

- `--force`: Skip all confirmation prompts
- `--backup`: Create a backup before dropping tables
- `--backup-path PATH`: Specify custom backup file path

## Interactive Mode

When run without `--force`, the command will ask:

1. **Backup confirmation**: "Do you want to create a backup before proceeding?"
2. **Path input** (if backup selected): Prompts for backup file path
3. **Final confirmation**: "Are you sure you want to continue?"

## Database Support

- **PostgreSQL**: Uses `pg_dump` for backups
- **MySQL**: Uses `mysqldump` for backups  
- **SQLite**: Simple file copy for backups

## Example Session

```bash
$ python manage.py migrate_fresh

🚀 Django Migrate Fresh
==================================================

💾 Do you want to create a backup before proceeding? [y/N]: y

📁 Enter backup path [backup_20231219_143022.sql]: my_backup.sql

⚠️  This will DROP ALL TABLES and re-run migrations.

🤔 Are you sure you want to continue? [y/N]: y

💾 Creating backup...
✅ Backup created: my_backup.sql
🔥 Dropping all tables...
🗑️  Dropped 15 tables
🏗️  Running migrations...
✨ Fresh migration completed!

✅ Migration completed successfully in 2.34 seconds!
```

## Requirements

- Django >= 3.2
- Python >= 3.8

## License

MIT License
