Skip to main content

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:

  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

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

django_migrate_fresh-3.1.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_migrate_fresh-3.1.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

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

Hashes for django_migrate_fresh-3.1.0.tar.gz
Algorithm Hash digest
SHA256 5db296b2e3da74d2802de4247b54ed69479747e84bf76e2de77a62149cb71756
MD5 177729c4f57bc3a9dca03b586fd61750
BLAKE2b-256 58a0ec6ee35e3be26c5cc0aef6797df6b17b111393eb629a2a68dfb02a3ade73

See more details on using hashes here.

File details

Details for the file django_migrate_fresh-3.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_migrate_fresh-3.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d8b148153fc38797e6fdee65891443b1acdd4fe64bd12473eeef91c38cd146eb
MD5 55192f243d37fa95c73d27e98068249c
BLAKE2b-256 3257d4fd24e123840983d71502dcb048efd5d4a728c88decb9885fba26629b9f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page