Skip to main content

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

Project description

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

pip install django-migrations-auto

Usage

1. Add to Installed Apps

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

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

2. Run Migrations

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:

python manage.py makemigrations [app_label]

auto_migrate

This command runs makemigrations and migrate automatically, storing migration files in the database.

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:

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 file for details.

Contact

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

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_migrations_auto-0.1.2.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

django_migrations_auto-0.1.2-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file django_migrations_auto-0.1.2.tar.gz.

File metadata

File hashes

Hashes for django_migrations_auto-0.1.2.tar.gz
Algorithm Hash digest
SHA256 aae72a5762a351e55a245e7c9100832def15c1602bbda9fb8634401bbf8bfe38
MD5 f4121410d4969f30706fc8189c6c2073
BLAKE2b-256 66860f4c62a952fa68e77e4bb12bb50bd3c50e3f910760b0759118e56a47aa84

See more details on using hashes here.

File details

Details for the file django_migrations_auto-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_migrations_auto-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 27e9fd047d9c6deb9821a08c62131f6605e7069615ebde4cb397727ba310feb3
MD5 875452ee7bc3d98a13e869b26fdc5df9
BLAKE2b-256 d4074cd4728668b3d72a9609cb23d7b08c9068ea09a581a5ae6ef9b1de7539e5

See more details on using hashes here.

Supported by

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