Skip to main content

django postgres model add/drop constraints statements

Project description

Installation

$ [sudo] pip install django-postgres-model-constraints

Pros

designed for Django projects with a large number of models:

  • no need makemigrations and migrate
  • no migration conflicts
  • integrity checks - drop and create constraints again
  • define tables with raw SQL (optional)

Examples

from django.apps import apps
from django_postgres_model_constraints.utils import get_add_foreign_key_constraint_statements, get_add_unique_constraint_statements


for model in apps.get_models():
    statements = get_add_unique_constraint_statements(
        model) + get_add_foreign_key_constraint_statements(model)
from django.apps import apps
from django_postgres_model_constraints.utils import get_drop_foreign_key_constraint_statements, get_drop_unique_constraint_statements


for model in apps.get_models():
    statements = get_drop_foreign_key_constraint_statements(
        model) + get_drop_unique_constraint_statements(model)

readme42.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

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