Skip to main content

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:

  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

$ 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

Metadata

Release files for django-migrate-fresh 3.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-migrate-fresh 3.1.0
File Size Uploaded
django_migrate_fresh-3.1.0.tar.gz 16.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-migrate-fresh 3.1.0
File Interpreter ABI Platform
django_migrate_fresh-3.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 33.2 kB

Release files / django_migrate_fresh-3.1.0.tar.gz

Download URL django_migrate_fresh-3.1.0.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5db296b2e3da74d2802de4247b54ed69479747e84bf76e2de77a62149cb71756
BLAKE2b-256 checksum
How to use checksums
58a0ec6ee35e3be26c5cc0aef6797df6b17b111393eb629a2a68dfb02a3ade73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / django_migrate_fresh-3.1.0-py3-none-any.whl

Download URL django_migrate_fresh-3.1.0-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d8b148153fc38797e6fdee65891443b1acdd4fe64bd12473eeef91c38cd146eb
BLAKE2b-256 checksum
How to use checksums
3257d4fd24e123840983d71502dcb048efd5d4a728c88decb9885fba26629b9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

3.1.0 This release

2 release files

3.0.0

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page