Simple Django package for Laravel-style migrate:fresh functionality with backup support
Project description
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
pip install django-migrate-fresh
Add to your INSTALLED_APPS:
INSTALLED_APPS = [
# ... your other apps
'django_migrate_fresh',
]
Usage
Basic Usage
Drop all tables and re-run migrations:
python manage.py migrate_fresh
With Backup
Create a backup before running:
python manage.py migrate_fresh --backup
Specify backup path:
python manage.py migrate_fresh --backup --backup-path my_backup.sql
Force Mode (No Confirmations)
Skip all confirmations:
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:
- Backup confirmation: "Do you want to create a backup before proceeding?"
- Path input (if backup selected): Prompts for backup file path
- Final confirmation: "Are you sure you want to continue?"
Database Support
- PostgreSQL: Uses
pg_dumpfor backups - MySQL: Uses
mysqldumpfor backups - SQLite: Simple file copy for backups
Example Session
$ 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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_migrate_fresh-3.1.0.tar.gz.
File metadata
- Download URL: django_migrate_fresh-3.1.0.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5db296b2e3da74d2802de4247b54ed69479747e84bf76e2de77a62149cb71756
|
|
| MD5 |
177729c4f57bc3a9dca03b586fd61750
|
|
| BLAKE2b-256 |
58a0ec6ee35e3be26c5cc0aef6797df6b17b111393eb629a2a68dfb02a3ade73
|
File details
Details for the file django_migrate_fresh-3.1.0-py3-none-any.whl.
File metadata
- Download URL: django_migrate_fresh-3.1.0-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8b148153fc38797e6fdee65891443b1acdd4fe64bd12473eeef91c38cd146eb
|
|
| MD5 |
55192f243d37fa95c73d27e98068249c
|
|
| BLAKE2b-256 |
3257d4fd24e123840983d71502dcb048efd5d4a728c88decb9885fba26629b9f
|