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
30.14k stars 3.81k forks source link

Drop unique constraint using "alter table" #42840

Open apantel opened 4 years ago

apantel commented 4 years ago

ALTER TABLE DROP CONSTRAINT cannot be used to drop UNIQUE constraints. This is allowed through DROP INDEX CASCADE.

Epic: CRDB-10239

Jira issue: CRDB-5317

rafiss commented 4 years ago

Liquibase uses the alter table syntax to drop unique constraints.

oneumyvakin commented 4 years ago

Laravel 7 Illuminate affected

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

Schema::table('settings', function (Blueprint $table) {
        $table->dropUnique('settings_name_unique');
        $table->string('group')->default('default');
});
ajwerner commented 2 years ago

More cross-refs: https://github.com/cockroachdb/cockroach/issues/65885 https://github.com/cockroachdb/cockroach/issues/65929

ajwerner commented 2 years ago

There was once upon a time, a half measure to allow this syntax for unique constraints which were not marked as "created explicitly" to be dropped in this way. It seems to have been removed at some point. My vote would be that we give up on this bookkeeping, or revive it, but either way, permit this syntax where it is reasonable.