cockroachdb / cockroach

CockroachDB — the cloud native, distributed SQL database designed for high availability, effortless scale, and control over data placement.
https://www.cockroachlabs.com
Other
29.96k stars 3.79k forks source link

sql: support DEFERRABLE INITIALLY for unique constraints #48307

Open timgraham opened 4 years ago

timgraham commented 4 years ago

Django 3.1 with PostgreSQL adds support for deferrable unique constraints which CockroachDB doesn't support. For example:

CREATE TABLE "constraints_uniqueconstraintdeferrable" (
    "id" integer NOT NULL PRIMARY KEY DEFAULT unique_rowid(),
    "name" varchar(255) NOT NULL,
    "shelf" varchar(31) NOT NULL,
    CONSTRAINT "name_init_deferred_uniq" UNIQUE ("name") DEFERRABLE INITIALLY DEFERRED,
    CONSTRAINT "sheld_init_immediate_uniq" UNIQUE ("shelf") DEFERRABLE INITIALLY IMMEDIATE
)

(https://github.com/cockroachdb/cockroach/issues/31632 is a related issue which requests this for foreign key constraints.)

Epic: CRDB-9559

Jira issue: CRDB-4334

robert-kisteleki commented 3 years ago

The referenced issue (#31632) has a comment "[this] feels like far future"... in the meantime CockroachDB latest is not compatible with Django latest...? :-(

timgraham commented 3 years ago

This limitation means that UniqueConstraint.deferrable isn't supported.

Use django-cockroachdb to use Django and CockroachDB.

knz commented 3 years ago

Related discussion: https://github.com/cockroachdb/cockroach/issues/31632#issuecomment-821829121

github-actions[bot] commented 1 year ago

We have marked this issue as stale because it has been inactive for 18 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to CockroachDB!