Smart Django migration manager.
Project description
djmigrator
djmigrator is a Django management extension that provides smart migration handling by deeply comparing Django models with the actual database schema. It automates missing migrations generation and applies them safely, ensuring that the models and database remain consistent without manually tracking changes.
Introduction
In large Django projects, inconsistencies between models and the actual database often happen due to missing migrations, manual database edits, or legacy systems. Traditional Django commands such as makemigrations and migrate assume perfect sync between models and the database.
djmigrator solves this by:
- Performing deep inspections of your actual database schema.
- Comparing models and fields directly against database tables and columns.
- Identifying missing tables or missing columns.
- Generating and applying only necessary migrations.
- Using smart application strategies to avoid common errors like "table already exists" or "column already exists".
Key Features
- Automatic detection of missing tables or missing columns based on model comparison.
- Safe skipping of already existing tables and fields during migration.
- Automatic generation of migration files only when necessary.
- Application of migrations with
--fake-initialto synchronize existing tables. - Clear reporting of discrepancies between models and database.
- Minimal downtime and human intervention required for database synchronization.
How It Works
- The
smart_makemigrationscommand inspects all Django models and their respective tables in the connected database. - It identifies:
- Tables missing in the database.
- Columns missing inside an existing table.
- Extra columns existing in the database but not defined in the Django models (reported but not modified).
- If discrepancies are found:
makemigrationsis automatically triggered to generate new migration files.migrate --fake-initialis applied to safely sync without duplicating existing tables.
- If no discrepancies are found, the command reports a clean synchronization status.
Installation and Setup
To install and set up djmigrator, follow these steps:
1. Install the Package
pip install djmigrator
### 2. Add to Django Settings
Add `djmigrator` to your Django project's `INSTALLED_APPS` in `settings.py`:
```python
INSTALLED_APPS = [
...
'djmigrator',
]
### 3. Migration Command
```bash
python manage.py smart_makemigrations
Project details
Release history Release notifications | RSS feed
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 djmigrator-1.0.5.tar.gz.
File metadata
- Download URL: djmigrator-1.0.5.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4a13a015cba2318272645f932b533ee8f0e1ac18bc69b54baf342712dab3e4a
|
|
| MD5 |
5f4428a4c91ec94017ce39829384d305
|
|
| BLAKE2b-256 |
0f4fb033bd013563fb96b9fc2b8040f670b94b991723089d401c11a102c9bce1
|
File details
Details for the file djmigrator-1.0.5-py3-none-any.whl.
File metadata
- Download URL: djmigrator-1.0.5-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
73460afd6845de0d19cc892f7e072f41097a11f5bfd0ca3ea2f78f704e09d37a
|
|
| MD5 |
3c4197ad788a8defab54f1027de70cf7
|
|
| BLAKE2b-256 |
9f6628275c82064ccb2fc1ff643977e94e6584e1c89f3fb4ae38fe8030004995
|