# 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
Raw data
{
"_id": null,
"home_page": "https://github.com/sepehr-mohseni/django-migrate-fresh",
"name": "django-migrate-fresh",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "django, migration, laravel, migrate, fresh, backup",
"author": "Sepehr Mohseni",
"author_email": "Sepehr Mohseni <isepehrmohseni@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/58/a0/ec6ee35e3be26c5cc0aef6797df6b17b111393eb629a2a68dfb02a3ade73/django_migrate_fresh-3.1.0.tar.gz",
"platform": null,
"description": "# Django Migrate Fresh \ud83d\ude80\n\nA simple Django package that provides Laravel-style `migrate:fresh` functionality - drop all tables and re-run migrations with optional backup support.\n\n## Installation\n\n```bash\npip install django-migrate-fresh\n```\n\nAdd to your `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n # ... your other apps\n 'django_migrate_fresh',\n]\n```\n\n## Usage\n\n### Basic Usage\n\nDrop all tables and re-run migrations:\n\n```bash\npython manage.py migrate_fresh\n```\n\n### With Backup\n\nCreate a backup before running:\n\n```bash\npython manage.py migrate_fresh --backup\n```\n\nSpecify backup path:\n\n```bash\npython manage.py migrate_fresh --backup --backup-path my_backup.sql\n```\n\n### Force Mode (No Confirmations)\n\nSkip all confirmations:\n\n```bash\npython manage.py migrate_fresh --force\n```\n\n## Command Options\n\n- `--force`: Skip all confirmation prompts\n- `--backup`: Create a backup before dropping tables\n- `--backup-path PATH`: Specify custom backup file path\n\n## Interactive Mode\n\nWhen run without `--force`, the command will ask:\n\n1. **Backup confirmation**: \"Do you want to create a backup before proceeding?\"\n2. **Path input** (if backup selected): Prompts for backup file path\n3. **Final confirmation**: \"Are you sure you want to continue?\"\n\n## Database Support\n\n- **PostgreSQL**: Uses `pg_dump` for backups\n- **MySQL**: Uses `mysqldump` for backups \n- **SQLite**: Simple file copy for backups\n\n## Example Session\n\n```bash\n$ python manage.py migrate_fresh\n\n\ud83d\ude80 Django Migrate Fresh\n==================================================\n\n\ud83d\udcbe Do you want to create a backup before proceeding? [y/N]: y\n\n\ud83d\udcc1 Enter backup path [backup_20231219_143022.sql]: my_backup.sql\n\n\u26a0\ufe0f This will DROP ALL TABLES and re-run migrations.\n\n\ud83e\udd14 Are you sure you want to continue? [y/N]: y\n\n\ud83d\udcbe Creating backup...\n\u2705 Backup created: my_backup.sql\n\ud83d\udd25 Dropping all tables...\n\ud83d\uddd1\ufe0f Dropped 15 tables\n\ud83c\udfd7\ufe0f Running migrations...\n\u2728 Fresh migration completed!\n\n\u2705 Migration completed successfully in 2.34 seconds!\n```\n\n## Requirements\n\n- Django >= 3.2\n- Python >= 3.8\n\n## License\n\nMIT License\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simple Django package for Laravel-style migrate:fresh functionality with backup support",
"version": "3.1.0",
"project_urls": {
"Homepage": "https://github.com/sepehr-mohseni/django-migrate-fresh",
"Issues": "https://github.com/sepehr-mohseni/django-migrate-fresh/issues",
"Repository": "https://github.com/sepehr-mohseni/django-migrate-fresh"
},
"split_keywords": [
"django",
" migration",
" laravel",
" migrate",
" fresh",
" backup"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "3257d4fd24e123840983d71502dcb048efd5d4a728c88decb9885fba26629b9f",
"md5": "55192f243d37fa95c73d27e98068249c",
"sha256": "d8b148153fc38797e6fdee65891443b1acdd4fe64bd12473eeef91c38cd146eb"
},
"downloads": -1,
"filename": "django_migrate_fresh-3.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "55192f243d37fa95c73d27e98068249c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 16412,
"upload_time": "2025-09-19T11:23:29",
"upload_time_iso_8601": "2025-09-19T11:23:29.156505Z",
"url": "https://files.pythonhosted.org/packages/32/57/d4fd24e123840983d71502dcb048efd5d4a728c88decb9885fba26629b9f/django_migrate_fresh-3.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "58a0ec6ee35e3be26c5cc0aef6797df6b17b111393eb629a2a68dfb02a3ade73",
"md5": "177729c4f57bc3a9dca03b586fd61750",
"sha256": "5db296b2e3da74d2802de4247b54ed69479747e84bf76e2de77a62149cb71756"
},
"downloads": -1,
"filename": "django_migrate_fresh-3.1.0.tar.gz",
"has_sig": false,
"md5_digest": "177729c4f57bc3a9dca03b586fd61750",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 16831,
"upload_time": "2025-09-19T11:23:30",
"upload_time_iso_8601": "2025-09-19T11:23:30.482061Z",
"url": "https://files.pythonhosted.org/packages/58/a0/ec6ee35e3be26c5cc0aef6797df6b17b111393eb629a2a68dfb02a3ade73/django_migrate_fresh-3.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-19 11:23:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "sepehr-mohseni",
"github_project": "django-migrate-fresh",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "Django",
"specs": [
[
">=",
"3.2"
]
]
},
{
"name": "pytest",
"specs": [
[
">=",
"8.0.0"
]
]
}
],
"lcname": "django-migrate-fresh"
}