Metadata-Version: 2.1
Name: django_migrations_auto
Version: 0.1.2
Summary: A Django app to store migrations in the database and apply them automatically.
Home-page: https://github.com/lmcc-dev/django_migrations_auto
Author: lmcc
Author-email: lmccc.dev@gmail.com
License: MIT License
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 4.1
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=3.2

# django-migrations-auto

A Django app to store migrations in the database and apply them automatically.

## Overview

`django-migrations-auto` is a Django application designed to manage database schema migrations by storing migration files in the database and applying them automatically. This approach simplifies deployment processes by reducing the need to maintain migration files across different environments.

### Key Features

- **Database Migration Logging**: Store migration files directly in the database.
- **Automatic Migration Application**: Automatically generate and apply migrations during deployment.
- **Version Control Integration**: Simplify version control by reducing the need to track migration files.
- **Custom Management Commands**: Enhanced `makemigrations` and `migrate` commands for streamlined migration management.
- **Environment and Database Consistency**: Ensure consistent deployment environments, databases, and migration files, eliminating the need to maintain different migration files in the version control repository.

## Installation

```bash
pip install django-migrations-auto
```


## Usage

### 1. Add to Installed Apps

Add `'django_migrations_auto.migrations_log'` to your `INSTALLED_APPS` in `settings.py`:

```python
INSTALLED_APPS = [
    ...
    'django_migrations_auto.migrations_log',
]
```

### 2. Run Migrations
```bash 
python manage.py migrate migrations_log
```
### 3. Custom Management Commands

#### `makemigrations`

This command generates new migrations based on the changes detected to your models.

Usage:

```bash
python manage.py makemigrations [app_label]
```
#### auto_migrate
This command runs makemigrations and migrate automatically, storing migration files in the database.
```bash 
python manage.py auto_migrate [app_label]
```

## Running Tests

To run the tests, first set up the test environment:

1. Ensure your `DATABASES` setting in `settings_test.py` points to a test database.

2.	Before running tests, ensure sqlite3 is updated by executing the `install_sqlite3.sh` script located in the test_app/scripts directory. This script checks the current version of sqlite3 and installs the required version if necessary.
3.	Run the tests using the following command:
```bash
DJANGO_SETTINGS_MODULE=django_migrations_auto.settings_test python manage.py test
```
#### install_sqlite3.sh Script

The install_sqlite3.sh script is located in the test_app/scripts directory and is used to ensure that the correct version of sqlite3 is installed. This script is particularly useful for environments where the default sqlite3 version does not meet the minimum requirements for the application.

## Compatibility

This package is compatible with Django versions 3.2 to 5.0 and requires Python 3.7 to 3.12.

## Contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss your changes.

### Steps to Contribute

1. Fork the repository.
2. Create your feature branch (`git checkout -b feature/your-feature`).
3. Commit your changes (`git commit -am 'Add some feature'`).
4. Push to the branch (`git push origin feature/your-feature`).
5. Create a new Pull Request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Contact

For any questions or suggestions, please open an issue or contact the maintainer at lmccc.dev@gmail.com.



