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

File details

Details for the file django-postgres-model-constraints-2020.7.1.tar.gz.

File metadata

  • Download URL: django-postgres-model-constraints-2020.7.1.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.7

File hashes

Hashes for django-postgres-model-constraints-2020.7.1.tar.gz
Algorithm Hash digest
SHA256 0b4039a81984281bb1c974a33ab70d839e54510ab8cca8ddac81efe698ccf97c
MD5 a755d0fa40ca6575e8617723fc5698b8
BLAKE2b-256 a98bf15467b05ccca57b26f58500cc19ea7d141eee692276cb56c66e2ddd4464

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